mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 03:06:34 +00:00

Label resolution gets into an infinite loop trying to emit an inappropriate error or warning for a GOTO whose target is on an enclosing END IF statement with an intervening ELSE or ELSE IF. The scope tracking mechanism viewed the END IF as being part of the ELSE block's scope. Fix with the same means that was used to fix a similar bogus error on GOTOs to END SELECT in SELECT CASE blocks: nest the THEN/ELSE IF/ELSE blocks one level deeper than before, so that the END IF is in the IF block but not in any of its parts. Fixes https://github.com/llvm/llvm-project/issues/64654 for llvm-test-suite/Fortran/gfortran/regression/goto_5.f90. Differential Revision: https://reviews.llvm.org/D159040
19 lines
468 B
Fortran
19 lines
468 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
|
|
program main
|
|
if (.true.) then
|
|
do j = 1, 2
|
|
goto 1 ! ok; used to cause looping in label resolution
|
|
end do
|
|
else
|
|
goto 1 ! ok
|
|
1 end if
|
|
if (.true.) then
|
|
do j = 1, 2
|
|
!WARNING: Label '1' is in a construct that should not be used as a branch target here
|
|
goto 1
|
|
end do
|
|
end if
|
|
!WARNING: Label '1' is in a construct that should not be used as a branch target here
|
|
goto 1
|
|
end
|