[flang] Detect circularly defined procedures
authorPeter Steinfeld <psteinfeld@nvidia.com>
Fri, 12 Feb 2021 21:28:58 +0000 (13:28 -0800)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Tue, 16 Feb 2021 22:40:35 +0000 (14:40 -0800)
commit77dc203cd0f65a8dbd71f3814e0cc3199c791980
tree576cb685401b81decbff78216f57541716ac5115
parentbfa4235e6e92ce2d3df486828ca2b6aef9705c07
[flang] Detect circularly defined procedures

It's possible to define a procedure that has a procedure dummy argument which
names the procedure that contains it.  This was causing the compiler to fall
into an infinite loop when characterizing a call to the procedure.

Following a suggestion from Peter, I fixed this be maintaining a set of
procedure symbols that had already been seen while characterizing a procedure.
This required passing a new parameter to the functions that characterized a
Procedure, a DummyArgument, and a DummyProcedure.

I also added several tests that will crash the compiler without this change.

Differential Revision: https://reviews.llvm.org/D96631
flang/include/flang/Evaluate/characteristics.h
flang/lib/Evaluate/characteristics.cpp
flang/test/Semantics/resolve102.f90 [new file with mode: 0644]