Peter Klausler 80f0bb5971 [flang] Distinguish error/warning cases for bad jumps into constructs
Previously, jumps to labels in constructs from exterior statements
would elicit only a warning.  Upgrade these to errors unless the
branch into the construct would enter into only DO, IF, and SELECT CASE
constructs, whose interiors don't scope variables or have other
set-up/tear-down semantics.  Branches into these "safe" constructs
are still errors if they're nested in an unsafe construct that doesn't
also enclose the exterior branch statement.

Differential Revision: https://reviews.llvm.org/D113310
2021-11-08 11:52:01 -08:00

62 lines
1.4 KiB
Fortran

! 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: 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
! CHECK: error: Label '90' is in a construct that prevents its use as a branch target here
! CHECK: error: Label '91' is in a construct that prevents its use as a branch target here
! CHECK: error: Label '92' is in a construct that prevents its use as a branch target here
subroutine sub00(a,b,n,m)
real a(n,m)
real b(n,m)
if (n .ne. m) then
goto 50
end if
6 n = m
end subroutine sub00
subroutine sub01(a,b,n,m)
real a(n,m)
real b(n,m)
if (n .ne. m) then
goto 55
else
55 continue
end if
60 n = m
end subroutine sub01
subroutine sub02(a,b,n,m)
real a(n,m)
real b(n,m)
if (n .ne. m) then
goto 70
else
return
end if
70 FORMAT (1x,i6)
end subroutine sub02
subroutine sub03(a,n)
real a(n)
forall (j=1:n)
80 a(n) = j
end forall
go to 80
end subroutine sub03
subroutine sub04(a,n)
real a(n)
where (a > 0)
90 a = 1
elsewhere (a < 0)
91 a = 2
elsewhere
92 a = 3
end where
if (n - 3) 90, 91, 92
end subroutine sub04