aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorpeter klausler <pklausler@nvidia.com>2020-11-10 15:03:21 -0800
committerpeter klausler <pklausler@nvidia.com>2020-11-11 13:06:19 -0800
commitb781a04f6aff145f43b6f87c5b987159c2b64123 (patch)
treef8a5997e624fd88ce877a15f7a3bc8c2704a2795 /clang/lib/Frontend/CompilerInvocation.cpp
parent0dd87825db2e73c2fb538f710217673ac15b7255 (diff)
downloadllvm-b781a04f6aff145f43b6f87c5b987159c2b64123.zip
llvm-b781a04f6aff145f43b6f87c5b987159c2b64123.tar.gz
llvm-b781a04f6aff145f43b6f87c5b987159c2b64123.tar.bz2
[flang] Allow labels on END statements.
F18 clause 5.3.3 explicitly allows labels on program unit END statements. Label resolution code accounts for this for singleton program units, but incorrectly generates an error for host subprograms with internal subprograms. subroutine s(n) call s1(n) if (n == 0) goto 88 ! incorrect error print*, 's' contains subroutine s1(n) if (n == 0) goto 77 ! ok print*, 's1' 77 end subroutine s1 88 end Label resolution code makes a sequential pass over an entire file to collect label information for all subprograms, followed by a pass through that information for semantics checks. The problem is that END statements may be separated from prior subprogram code by internal subprogram definitions, so an END label can be associated with the wrong subprogram. There are several ways to fix this. Labels are always local to a subprogram. So the two separate passes over the entire file could probably instead be interleaved to perform analysis on a subprogram as soon as the end of the subprogram is reached, using a small stack. The stack structure would account for the "split" code case. This might work. It is possible that there is some not otherwise apparent advantage to the current full-file pass design. The parse tree has productions that provide access to a subprogram END statement "in advance". An alternative is to access this information to solve the problem. This PR implements this latter option. Differential revision: https://reviews.llvm.org/D91217
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions