[flang] Handle undeclared names in EQUIVALENCE statements
authorPeter Steinfeld <psteinfeld@nvidia.com>
Tue, 15 Dec 2020 22:44:22 +0000 (14:44 -0800)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Wed, 16 Dec 2020 19:04:27 +0000 (11:04 -0800)
commit4e90cad6a6b5504f11b7876e26e80c2a079e04b0
tree36a992a81f12499a9675467e6b9410aeedef4869
parent869f8363c424592e5f8c258492f46d5fcbc90c83
[flang] Handle undeclared names in EQUIVALENCE statements

Names in EQUIVALENCE statements are only allowed to indicate local
objects as per 19.5.1.4, paragraph 2, item (10).  Thus, a name appearing
in an EQUIVALENCE statement with no corresponding declaration in the
same scope is an implicit declaration of the name.  If that scope
contains an IMPLICIT NONE, it's an error.

I implemented this by adding a state variable to ScopeHandler to
indicate if we're resolving the names in an EQUIVALENCE statement and
then checked this state when resolving names.  I also added a test to
the existing tests for EQUIVALENCE statements.

Differential Revision: https://reviews.llvm.org/D93345
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/equivalence01.f90