diff --git a/flang/lib/semantics/resolve-labels.cc b/flang/lib/semantics/resolve-labels.cc index 2486ae770cc3..b146f85949f2 100644 --- a/flang/lib/semantics/resolve-labels.cc +++ b/flang/lib/semantics/resolve-labels.cc @@ -326,13 +326,11 @@ public: std::get>(blockData.t) .statement.v)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END BLOCK DATA name mismatch"_err_en_US}) + .Say(currentPosition_, "END BLOCK DATA name mismatch"_err_en_US) .Attach( std::get>(blockData.t) .source, - "mismatched from here"_en_US); + "mismatched BLOCK DATA"_en_US); } } // C1564 @@ -346,13 +344,11 @@ public: functionSubprogram.t) .statement.t))) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END FUNCTION name mismatch"_err_en_US}) + .Say(currentPosition_, "END FUNCTION name mismatch"_err_en_US) .Attach(std::get>( functionSubprogram.t) .source, - "mismatched from here"_en_US); + "mismatched FUNCTION"_en_US); } } void Post(const parser::InterfaceBlock &interfaceBlock) { @@ -377,7 +373,7 @@ public: parser::MessageFormattedText{ "INTERFACE generic-name (%s) mismatch"_en_US, namePointer->ToString().c_str()}) - .Attach(interfaceStmt.source, "mismatched from here"_en_US); + .Attach(interfaceStmt.source, "mismatched INTERFACE"_en_US); } } } @@ -392,13 +388,10 @@ public: .statement.v, std::get>(module.t) .statement.v)) { - errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END MODULE name mismatch"_err_en_US}) + errorHandler_.Say(currentPosition_, "END MODULE name mismatch"_err_en_US) .Attach( std::get>(module.t).source, - "mismatched from here"_en_US); + "mismatched MODULE"_en_US); } } // C1569 @@ -411,13 +404,11 @@ public: separateModuleSubprogram.t) .statement.v)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END MODULE PROCEDURE name mismatch"_err_en_US}) + .Say(currentPosition_, "END MODULE PROCEDURE name mismatch"_err_en_US) .Attach(std::get>( separateModuleSubprogram.t) .source, - "mismatched from here"_en_US); + "mismatched MODULE PROCEDURE"_en_US); } } // C1401 @@ -435,15 +426,13 @@ public: if (endProgramStmt.v.has_value()) { if (programStmt.v.ToString() != endProgramStmt.v->ToString()) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END PROGRAM name mismatch"_err_en_US}) + .Say(currentPosition_, "END PROGRAM name mismatch"_err_en_US) .Attach( std::get< std::optional>>( mainProgram.t) ->source, - "mismatched from here"_en_US); + "mismatched PROGRAM"_en_US); } } } else { @@ -464,13 +453,11 @@ public: std::get>(submodule.t) .statement.t))) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END SUBMODULE name mismatch"_err_en_US}) + .Say(currentPosition_, "END SUBMODULE name mismatch"_err_en_US) .Attach( std::get>(submodule.t) .source, - "mismatched from here"_en_US); + "mismatched SUBMODULE"_en_US); } } // C1567 @@ -484,13 +471,11 @@ public: subroutineSubprogram.t) .statement.t))) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "END SUBROUTINE name mismatch"_err_en_US}) + .Say(currentPosition_, "END SUBROUTINE name mismatch"_err_en_US) .Attach(std::get>( subroutineSubprogram.t) .source, - "mismatched from here"_en_US); + "mismatched SUBROUTINE"_en_US); } } // C739 @@ -502,13 +487,11 @@ public: std::get>( derivedTypeDef.t) .statement.t))) { - errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{"END TYPE name mismatch"_err_en_US}) + errorHandler_.Say(currentPosition_, "END TYPE name mismatch"_err_en_US) .Attach(std::get>( derivedTypeDef.t) .source, - "mismatched from here"_en_US); + "mismatched TYPE"_en_US); } } @@ -674,7 +657,7 @@ private: .Say(currentPosition_, parser::MessageFormattedText{ "%s construct name mismatch"_err_en_US, constructTag}) - .Attach(std::get<0>(a.t).source, "mismatched from here"_en_US); + .Attach(std::get<0>(a.t).source, "mismatched construct"_en_US); } } @@ -686,13 +669,11 @@ private: std::get>(blockConstruct.t) .statement.v)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "BLOCK construct name mismatch"_err_en_US}) + .Say(currentPosition_, "BLOCK construct name mismatch"_err_en_US) .Attach( std::get>(blockConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched BLOCK"_en_US); } } // C1112 @@ -707,13 +688,12 @@ private: changeTeamConstruct.t) .statement.t))) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "CHANGE TEAM construct name mismatch"_err_en_US}) + .Say( + currentPosition_, "CHANGE TEAM construct name mismatch"_err_en_US) .Attach(std::get>( changeTeamConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched CHANGE TEAM"_en_US); } } @@ -726,12 +706,10 @@ private: std::get>(ifConstruct.t) .statement.v)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "IF construct name mismatch"_err_en_US}) + .Say(currentPosition_, "IF construct name mismatch"_err_en_US) .Attach(std::get>(ifConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched IF"_en_US); } for (const auto &elseIfBlock : std::get>(ifConstruct.t)) { @@ -741,13 +719,11 @@ private: .statement.t), constructName)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "ELSE IF statement name mismatch"_err_en_US}) + .Say(currentPosition_, "ELSE IF statement name mismatch"_err_en_US) .Attach( std::get>(ifConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched IF"_en_US); } } if (std::get>(ifConstruct.t) @@ -760,13 +736,11 @@ private: .statement.v, constructName)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "ELSE statement name mismatch"_err_en_US}) + .Say(currentPosition_, "ELSE statement name mismatch"_err_en_US) .Attach( std::get>(ifConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched IF"_en_US); } } } @@ -781,7 +755,8 @@ private: .Say(currentPosition_, parser::MessageFormattedText{ "SELECT %s construct name mismatch"_err_en_US, selectTag}) - .Attach(std::get<0>(a.t).source, "mismatched from here"_en_US); + .Attach(std::get<0>(a.t).source, + parser::MessageFormattedText{"mismatched %s"_en_US, selectTag}); } for (const auto &subpart : std::get<1>(a.t)) { if (!firstNameNoneOrBothEqual(std::get>( @@ -791,7 +766,8 @@ private: .Say(currentPosition_, parser::MessageFormattedText{ "%sCASE statement name mismatch"_err_en_US, selectSubTag}) - .Attach(std::get<0>(a.t).source, "mismatched from here"_en_US); + .Attach(std::get<0>(a.t).source, + parser::MessageFormattedText{"mismatched %s"_en_US, selectTag}); } } } @@ -806,13 +782,11 @@ private: std::get>(whereConstruct.t) .statement.v)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "WHERE construct name mismatch"_err_en_US}) + .Say(currentPosition_, "WHERE construct name mismatch"_err_en_US) .Attach(std::get>( whereConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched WHERE"_en_US); } for (const auto &maskedElsewhere : std::get>( @@ -825,12 +799,11 @@ private: constructName)) { errorHandler_ .Say(currentPosition_, - parser::MessageFormattedText{ - "ELSEWHERE () statement name mismatch"_err_en_US}) + "ELSEWHERE () statement name mismatch"_err_en_US) .Attach(std::get>( whereConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched WHERE"_en_US); } } if (std::get>( @@ -844,13 +817,12 @@ private: .statement.v, constructName)) { errorHandler_ - .Say(currentPosition_, - parser::MessageFormattedText{ - "ELSEWHERE statement name mismatch"_err_en_US}) + .Say( + currentPosition_, "ELSEWHERE statement name mismatch"_err_en_US) .Attach(std::get>( whereConstruct.t) .source, - "mismatched from here"_en_US); + "mismatched WHERE"_en_US); } } } @@ -972,11 +944,8 @@ void CheckBranchesIntoDoBody(const SourceStmtList &branches, for (const auto body : loopBodies) { if (!InBody(fromPosition, body) && InBody(toPosition, body)) { errorHandler - .Say(body.first, - parser::MessageFormattedText{ - "branch into loop body from outside"_en_US}) - .Attach(toPosition, "to here"_en_US) - .Attach(fromPosition, "from here"_en_US); + .Say(fromPosition, "branch into loop body from outside"_en_US) + .Attach(body.first, "the loop branched into"_en_US); } } } @@ -991,13 +960,8 @@ void CheckDoNesting( const auto &v2{*i2}; if (v2.first.begin() < v1.second.end() && v1.second.begin() < v2.second.begin()) { - errorHandler - .Say(v1.first, - parser::MessageFormattedText{ - "DO loop doesn't properly nest"_err_en_US}) - .Attach(v1.second, "which extends to here"_en_US) - .Attach(v2.first, "and conflicts with the loop"_en_US) - .Attach(v2.second, "which extends to here"_en_US); + errorHandler.Say(v1.first, "DO loop doesn't properly nest"_err_en_US) + .Attach(v2.first, "DO loop conflicts"_en_US); } } } @@ -1032,19 +996,15 @@ void CheckLabelDoConstraints(const SourceStmtList &dos, "label '%u' cannot be found"_err_en_US, sayLabel(label)}); } else if (doTarget.parserCharBlock.begin() < position.begin()) { // R1119 - errorHandler - .Say(position, - parser::MessageFormattedText{ - "label '%u' doesn't lexically follow DO stmt"_err_en_US, - sayLabel(label)}) - .Attach(doTarget.parserCharBlock, "references here"_en_US); + errorHandler.Say(position, + parser::MessageFormattedText{ + "label '%u' doesn't lexically follow DO stmt"_err_en_US, + sayLabel(label)}); } else if (!InInclusiveScope(scopes, scope, doTarget.proxyForScope)) { // C1133 - errorHandler - .Say(position, - parser::MessageFormattedText{ - "label '%u' is not in scope"_en_US, sayLabel(label)}) - .Attach(doTarget.parserCharBlock, "references here"_en_US); + errorHandler.Say(position, + parser::MessageFormattedText{ + "label '%u' is not in scope"_en_US, sayLabel(label)}); } else if (!doTarget.labeledStmtClassificationSet.test( TargetStatementEnum::Do) && !doTarget.labeledStmtClassificationSet.test( @@ -1080,11 +1040,9 @@ void CheckScopeConstraints(const SourceStmtList &stmts, parser::MessageFormattedText{ "label '%u' was not found"_err_en_US, sayLabel(label)}); } else if (!InInclusiveScope(scopes, scope, target.proxyForScope)) { - errorHandler - .Say(position, - parser::MessageFormattedText{ - "label '%u' is not in scope"_en_US, sayLabel(label)}) - .Attach(target.parserCharBlock, "references here"_en_US); + errorHandler.Say(position, + parser::MessageFormattedText{ + "label '%u' is not in scope"_en_US, sayLabel(label)}); } } } @@ -1103,14 +1061,18 @@ void CheckBranchTargetConstraints(const SourceStmtList &stmts, .Say(branchTarget.parserCharBlock, parser::MessageFormattedText{ "'%u' not a branch target"_err_en_US, sayLabel(label)}) - .Attach(stmt.parserCharBlock, "referenced from here"_en_US); + .Attach(stmt.parserCharBlock, + parser::MessageFormattedText{ + "control flow use of '%u'"_en_US, sayLabel(label)}); } else if (!branchTarget.labeledStmtClassificationSet.test( TargetStatementEnum::Branch)) { errorHandler .Say(branchTarget.parserCharBlock, parser::MessageFormattedText{ "'%u' not a branch target"_en_US, sayLabel(label)}) - .Attach(stmt.parserCharBlock, "referenced from here"_en_US); + .Attach(stmt.parserCharBlock, + parser::MessageFormattedText{ + "control flow use of '%u'"_en_US, sayLabel(label)}); } } } @@ -1135,7 +1097,9 @@ void CheckDataXferTargetConstraints(const SourceStmtList &stmts, .Say(ioTarget.parserCharBlock, parser::MessageFormattedText{ "'%u' not a FORMAT"_err_en_US, sayLabel(label)}) - .Attach(stmt.parserCharBlock, "referenced from here"_en_US); + .Attach(stmt.parserCharBlock, + parser::MessageFormattedText{ + "data transfer use of '%u'"_en_US, sayLabel(label)}); } } } diff --git a/flang/test/semantics/label03.f90 b/flang/test/semantics/label03.f90 index 5c4c5291b06c..a23d481a0249 100644 --- a/flang/test/semantics/label03.f90 +++ b/flang/test/semantics/label03.f90 @@ -16,8 +16,7 @@ ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s ! CHECK: DO loop doesn't properly nest -! CHECK: and conflicts with the loop -! CHECK: which extends to here +! CHECK: DO loop conflicts ! CHECK: label '30' cannot be found ! CHECK: label '40' cannot be found ! CHECK: label '50' doesn't lexically follow DO stmt diff --git a/flang/test/semantics/label04.f90 b/flang/test/semantics/label04.f90 index 9bf6149e5446..bd5ecee966a8 100644 --- a/flang/test/semantics/label04.f90 +++ b/flang/test/semantics/label04.f90 @@ -17,9 +17,8 @@ ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s ! CHECK: branch into loop body from outside ! CHECK: do 10 i = 1, m +! CHECK: the loop branched into ! CHECK: do 20 j = 1, n -! CHECK: to here -! CHECK: from here subroutine sub00(a,b,n,m) real a(n,m) diff --git a/flang/test/semantics/label05.f90 b/flang/test/semantics/label05.f90 index 9e787627c7e9..ed4317fa2bec 100644 --- a/flang/test/semantics/label05.f90 +++ b/flang/test/semantics/label05.f90 @@ -18,8 +18,7 @@ ! CHECK: label '50' was not found ! CHECK: label '55' is not in scope ! CHECK: '70' not a branch target -! CHECK: referenced from here -! CHECK: references here +! CHECK: control flow use of '70' subroutine sub00(a,b,n,m) real a(n,m) diff --git a/flang/test/semantics/label06.f90 b/flang/test/semantics/label06.f90 index 8e95d3553f5a..86d9d34b5819 100644 --- a/flang/test/semantics/label06.f90 +++ b/flang/test/semantics/label06.f90 @@ -17,10 +17,10 @@ ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s ! CHECK: label '10' is not in scope ! CHECK: label '20' was not found +! CHECK: '30' not a branch target +! CHECK: control flow use of '30' ! CHECK: label '40' is not in scope ! CHECK: label '50' is not in scope -! CHECK: referenced from here -! CHECK: references here subroutine sub00(n) GOTO (10,20,30) n diff --git a/flang/test/semantics/label07.f90 b/flang/test/semantics/label07.f90 index 44d18c93a0ed..f5a9b84d9700 100644 --- a/flang/test/semantics/label07.f90 +++ b/flang/test/semantics/label07.f90 @@ -15,12 +15,11 @@ ! negative test -- invalid labels, out of range ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s +! CHECK: '30' not a branch target +! CHECK: control flow use of '30' ! CHECK: label '10' is not in scope ! CHECK: label '20' was not found -! CHECK: '30' not a branch target ! CHECK: label '60' was not found -! CHECK: referenced from here -! CHECK: references here subroutine sub00(n,m) 30 format (i6,f6.2) diff --git a/flang/test/semantics/label08.f90 b/flang/test/semantics/label08.f90 index bf7bbb180dcd..52d78d4f4f76 100644 --- a/flang/test/semantics/label08.f90 +++ b/flang/test/semantics/label08.f90 @@ -15,10 +15,11 @@ ! negative test -- invalid labels, out of range ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s -! CHECK: IF construct name mismatch -! CHECK: mismatched from here -! CHECK: DO construct name mismatch ! CHECK: CYCLE construct-name 'label3' is not in scope +! CHECK: IF construct name mismatch +! CHECK: mismatched IF +! CHECK: DO construct name mismatch +! CHECK: mismatched construct subroutine sub00(a,b,n,m) real a(n,m) diff --git a/flang/test/semantics/label10.f90 b/flang/test/semantics/label10.f90 index 534f6b4609ed..090022842b96 100644 --- a/flang/test/semantics/label10.f90 +++ b/flang/test/semantics/label10.f90 @@ -14,7 +14,7 @@ ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s ! CHECK: '60' not a FORMAT -! CHECK: referenced from here +! CHECK: data transfer use of '60' subroutine s(a) real a(10) diff --git a/flang/test/semantics/label11.f90 b/flang/test/semantics/label11.f90 index e4450173fd1b..fdd645056dcb 100644 --- a/flang/test/semantics/label11.f90 +++ b/flang/test/semantics/label11.f90 @@ -14,15 +14,23 @@ ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s ! CHECK: END BLOCK DATA name mismatch -! CHECK: mismatched from here +! CHECK: mismatched BLOCK DATA ! CHECK: END FUNCTION name mismatch +! CHECK: mismatched FUNCTION ! CHECK: END SUBROUTINE name mismatch +! CHECK: mismatched SUBROUTINE ! CHECK: END PROGRAM name mismatch +! CHECK: mismatched PROGRAM ! CHECK: END SUBMODULE name mismatch +! CHECK: mismatched SUBMODULE +! CHECK: INTERFACE generic-name .t7. mismatch +! CHECK: mismatched INTERFACE ! CHECK: END TYPE name mismatch -! CHECK: END MODULE name mismatch -! CHECK: INTERFACE generic-name +! CHECK: mismatched TYPE ! CHECK: END MODULE PROCEDURE name mismatch +! CHECK: mismatched MODULE PROCEDURE +! CHECK: END MODULE name mismatch +! CHECK: mismatched MODULE block data t1 end block data t2