[flang-commits] [PATCH] D127425: [flang] Fix bogus branch target error on END SELECT
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jun 13 11:43:15 PDT 2022
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee9c9170480a: [flang] Fix bogus branch target error on END SELECT (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127425/new/
https://reviews.llvm.org/D127425
Files:
flang/lib/Semantics/resolve-labels.cpp
flang/test/Semantics/label05.f90
flang/test/Semantics/label06.f90
flang/test/Semantics/label07.f90
Index: flang/test/Semantics/label07.f90
===================================================================
--- flang/test/Semantics/label07.f90
+++ flang/test/Semantics/label07.f90
@@ -1,7 +1,7 @@
! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '30' is not a branch target
! CHECK: Control flow use of '30'
-! CHECK: Label '10' is in a construct that prevents its use as a branch target here
+! CHECK: warning: Label '10' is in a construct that should not be used as a branch target here
! CHECK: Label '20' was not found
! CHECK: Label '60' was not found
Index: flang/test/Semantics/label06.f90
===================================================================
--- flang/test/Semantics/label06.f90
+++ flang/test/Semantics/label06.f90
@@ -1,10 +1,10 @@
! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
-! CHECK: Label '10' is in a construct that prevents its use as a branch target here
+! CHECK: warning: Label '10' is in a construct that should not be used as a branch target here
! CHECK: Label '20' was not found
! CHECK: Label '30' is not a branch target
! CHECK: Control flow use of '30'
-! CHECK: Label '40' is in a construct that prevents its use as a branch target here
-! CHECK: Label '50' is in a construct that prevents its use as a branch target here
+! CHECK: warning: Label '40' is in a construct that should not be used as a branch target here
+! CHECK: warning: Label '50' is in a construct that should not be used as a branch target here
subroutine sub00(n)
GOTO (10,20,30) n
Index: flang/test/Semantics/label05.f90
===================================================================
--- flang/test/Semantics/label05.f90
+++ flang/test/Semantics/label05.f90
@@ -1,7 +1,6 @@
! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '50' was not found
-! CHECK-NOT: error: Label '55' is in a construct that prevents its use as a branch target here
-! CHECK: Label '55' is in a construct that prevents its use as a branch target here
+! CHECK: warning: Label '55' is in a construct that should not be used as a branch target here
! CHECK: Label '70' is not a branch target
! CHECK: Control flow use of '70'
! CHECK: error: Label '80' is in a construct that prevents its use as a branch target here
Index: flang/lib/Semantics/resolve-labels.cpp
===================================================================
--- flang/lib/Semantics/resolve-labels.cpp
+++ flang/lib/Semantics/resolve-labels.cpp
@@ -233,13 +233,16 @@
using LabeledConstructEndStmts = std::tuple<parser::EndAssociateStmt,
parser::EndBlockStmt, parser::EndChangeTeamStmt,
parser::EndCriticalStmt, parser::EndDoStmt, parser::EndForallStmt,
- parser::EndIfStmt, parser::EndSelectStmt, parser::EndWhereStmt>;
+ parser::EndIfStmt, parser::EndWhereStmt>;
using LabeledProgramUnitEndStmts =
std::tuple<parser::EndFunctionStmt, parser::EndMpSubprogramStmt,
parser::EndProgramStmt, parser::EndSubroutineStmt>;
auto targetFlags{ConstructBranchTargetFlags(statement)};
if constexpr (common::HasMember<A, LabeledConstructStmts>) {
AddTargetLabelDefinition(label.value(), targetFlags, ParentScope());
+ } else if constexpr (std::is_same_v<A, parser::EndSelectStmt>) {
+ // the label on an END SELECT is not in the last case
+ AddTargetLabelDefinition(label.value(), targetFlags, ParentScope(), true);
} else if constexpr (common::HasMember<A, LabeledConstructEndStmts>) {
constexpr bool isExecutableConstructEndStmt{true};
AddTargetLabelDefinition(label.value(), targetFlags, currentScope_,
@@ -286,19 +289,23 @@
bool Pre(const parser::CaseConstruct &caseConstruct) {
return PushConstructName(caseConstruct);
}
+ void Post(const parser::SelectCaseStmt &) { PushScope(); }
bool Pre(const parser::CaseConstruct::Case &) { return SwitchToNewScope(); }
bool Pre(const parser::SelectRankConstruct &selectRankConstruct) {
return PushConstructName(selectRankConstruct);
}
+ void Post(const parser::SelectRankStmt &) { PushScope(); }
bool Pre(const parser::SelectRankConstruct::RankCase &) {
return SwitchToNewScope();
}
bool Pre(const parser::SelectTypeConstruct &selectTypeConstruct) {
return PushConstructName(selectTypeConstruct);
}
+ void Post(const parser::SelectTypeStmt &) { PushScope(); }
bool Pre(const parser::SelectTypeConstruct::TypeCase &) {
return SwitchToNewScope();
}
+ void Post(const parser::EndSelectStmt &) { PopScope(); }
bool Pre(const parser::WhereConstruct &whereConstruct) {
return PushConstructName(whereConstruct);
}
@@ -994,7 +1001,7 @@
context.Say(position,
isFatal
? "Label '%u' is in a construct that prevents its use as a branch target here"_err_en_US
- : "Label '%u' is in a construct that prevents its use as a branch target here"_en_US,
+ : "Label '%u' is in a construct that should not be used as a branch target here"_warn_en_US,
SayLabel(label));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127425.436497.patch
Type: text/x-patch
Size: 5140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220613/7d793917/attachment-0001.bin>
More information about the flang-commits
mailing list