This is an archive of the discontinued LLVM Phabricator instance.

[flang] Allow GOTO to containing END IF after ELSE
ClosedPublic

Authored by klausler on Aug 28 2023, 4:55 PM.

Details

Summary

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.

Diff Detail

Event Timeline

klausler created this revision.Aug 28 2023, 4:55 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Aug 28 2023, 4:55 PM
This revision is now accepted and ready to land.Aug 28 2023, 5:02 PM
klausler updated this revision to Diff 554110.Aug 28 2023, 5:03 PM

Add omitted test case.

This revision was automatically updated to reflect the committed changes.