[flang-commits] [PATCH] D86885: [flang] Format label scope is independent of block scope
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Aug 31 11:54:02 PDT 2020
klausler created this revision.
klausler added reviewers: sscalpone, PeteSteinfeld.
klausler added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
klausler requested review of this revision.
Compilation of the following program currently generates a warning message:
i = 1
if (i .eq. 0) then
write(6, 200) i
200 format (I8)
end if
write(6, 200) i
end
x.f90:6:9: Label '200' is not in scope
write(6, 200) i
^^^^^^^^^^^^^^^
Whereas branch targets must conform to the Clause 11.1.2.1 program
requirement "Transfer of control to the interior of a block from
outside the block is prohibited, ...", this doesn't apply to format
statement references.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86885
Files:
flang/lib/Semantics/resolve-labels.cpp
flang/test/Semantics/io07.f90
Index: flang/test/Semantics/io07.f90
===================================================================
--- flang/test/Semantics/io07.f90
+++ flang/test/Semantics/io07.f90
@@ -17,6 +17,11 @@
2011 format(:2L2)
2012 format(2L2 : 2L2)
+ write(*,2013) 'Hello'
+ if (2+2.eq.4) then
+2013 format(A10) ! ok to reference outside the if block
+ endif
+
! C1302 warnings; no errors
2051 format(1X3/)
2052 format(1X003/)
Index: flang/lib/Semantics/resolve-labels.cpp
===================================================================
--- flang/lib/Semantics/resolve-labels.cpp
+++ flang/lib/Semantics/resolve-labels.cpp
@@ -935,6 +935,12 @@
parser::MessageFormattedText{
"Label '%u' was not found"_err_en_US, SayLabel(label)});
} else if (!InInclusiveScope(scopes, scope, target.proxyForScope)) {
+ // Clause 11.1.2.1 prohibits transfer of control to the interior of a
+ // block from outside the block, but this does not apply to formats.
+ if (target.labeledStmtClassificationSet.test(
+ TargetStatementEnum::Format)) {
+ continue;
+ }
context.Say(position,
parser::MessageFormattedText{
"Label '%u' is not in scope"_en_US, SayLabel(label)});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86885.288997.patch
Type: text/x-patch
Size: 1266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200831/92d6686b/attachment.bin>
More information about the flang-commits
mailing list