[flang] Don't resolve component names to components in derived-type definition scope
authorPeter Klausler <pklausler@nvidia.com>
Mon, 24 Oct 2022 18:22:22 +0000 (11:22 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Sun, 30 Oct 2022 20:37:47 +0000 (13:37 -0700)
commitf8dbe79cc673439db4b90cdcabcffc79348a2ca1
tree7aafa34aa6164edeb47944281248cf17ae5883ec
parentc4c198f603d78ae328b517273df7ae8fb01a095c
[flang] Don't resolve component names to components in derived-type definition scope

We implemented 19.3.4p1 literally in name resolution:

  A component name has the scope of its derived-type definition. Outside the type definition,
  it may also appear within a designator of a component of a structure of that type or as a
  component keyword in a structure constructor for that type.

and within the derived-type definition would resolve the "bare"
names of components in specification inquiries and other contexts to
those components, not to any symbols in the enclosing scopes.

It turns out that most Fortran compilers resolve only "bare" names thus
when they are type parameters, and the names of data and procedure components
do not shadow exterior symbols.  Adjust name resolution to follow that
precedent rather than what seems to be clear language in the standard.

Differential Revision: https://reviews.llvm.org/D136984
flang/docs/Extensions.md
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve104.f90
flang/test/Semantics/symbol14.f90