[flang] Format label scope is independent of block scope
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.
This commit is contained in:
parent
8931add617
commit
646f19bb9d
|
@ -935,6 +935,12 @@ void CheckScopeConstraints(const SourceStmtList &stmts,
|
|||
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)});
|
||||
|
|
|
@ -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/)
|
||||
|
|
Loading…
Reference in a new issue