[flang] Tweak the error messages to not use "here" like gcc does.

Original-commit: flang-compiler/f18@cb5da3d4e4
Reviewed-on: https://github.com/flang-compiler/f18/pull/185
Tree-same-pre-rewrite: false
This commit is contained in:
Eric Schweitz 2018-10-15 12:33:56 -07:00 committed by GitHub
parent 2ced09610b
commit 0df55dace7
9 changed files with 86 additions and 117 deletions

View File

@ -326,13 +326,11 @@ public:
std::get<parser::Statement<parser::BlockDataStmt>>(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<parser::Statement<parser::BlockDataStmt>>(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<parser::Statement<parser::FunctionStmt>>(
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<parser::Statement<parser::ModuleStmt>>(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<parser::Statement<parser::ModuleStmt>>(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<parser::Statement<parser::MpSubprogramStmt>>(
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<parser::Statement<parser::ProgramStmt>>>(
mainProgram.t)
->source,
"mismatched from here"_en_US);
"mismatched PROGRAM"_en_US);
}
}
} else {
@ -464,13 +453,11 @@ public:
std::get<parser::Statement<parser::SubmoduleStmt>>(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<parser::Statement<parser::SubmoduleStmt>>(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<parser::Statement<parser::SubroutineStmt>>(
subroutineSubprogram.t)
.source,
"mismatched from here"_en_US);
"mismatched SUBROUTINE"_en_US);
}
}
// C739
@ -502,13 +487,11 @@ public:
std::get<parser::Statement<parser::DerivedTypeStmt>>(
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<parser::Statement<parser::DerivedTypeStmt>>(
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<parser::Statement<parser::EndBlockStmt>>(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<parser::Statement<parser::BlockStmt>>(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<parser::Statement<parser::ChangeTeamStmt>>(
changeTeamConstruct.t)
.source,
"mismatched from here"_en_US);
"mismatched CHANGE TEAM"_en_US);
}
}
@ -726,12 +706,10 @@ private:
std::get<parser::Statement<parser::EndIfStmt>>(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<parser::Statement<parser::IfThenStmt>>(ifConstruct.t)
.source,
"mismatched from here"_en_US);
"mismatched IF"_en_US);
}
for (const auto &elseIfBlock :
std::get<std::list<parser::IfConstruct::ElseIfBlock>>(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<parser::Statement<parser::IfThenStmt>>(ifConstruct.t)
.source,
"mismatched from here"_en_US);
"mismatched IF"_en_US);
}
}
if (std::get<std::optional<parser::IfConstruct::ElseBlock>>(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<parser::Statement<parser::IfThenStmt>>(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<std::optional<parser::Name>>(
@ -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<parser::Statement<parser::EndWhereStmt>>(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<parser::Statement<parser::WhereConstructStmt>>(
whereConstruct.t)
.source,
"mismatched from here"_en_US);
"mismatched WHERE"_en_US);
}
for (const auto &maskedElsewhere :
std::get<std::list<parser::WhereConstruct::MaskedElsewhere>>(
@ -825,12 +799,11 @@ private:
constructName)) {
errorHandler_
.Say(currentPosition_,
parser::MessageFormattedText{
"ELSEWHERE (<mask>) statement name mismatch"_err_en_US})
"ELSEWHERE (<mask>) statement name mismatch"_err_en_US)
.Attach(std::get<parser::Statement<parser::WhereConstructStmt>>(
whereConstruct.t)
.source,
"mismatched from here"_en_US);
"mismatched WHERE"_en_US);
}
}
if (std::get<std::optional<parser::WhereConstruct::Elsewhere>>(
@ -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<parser::Statement<parser::WhereConstructStmt>>(
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)});
}
}
}

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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