[flang] Don't prematurely resolve subprogram names
authorPeter Klausler <pklausler@nvidia.com>
Thu, 19 May 2022 21:17:17 +0000 (14:17 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 24 May 2022 20:34:58 +0000 (13:34 -0700)
commitcd2a8df8916505de9df68b9a6c1700f71e5ebf44
tree1559046097e1dfb6a25d3737d953ff1b04333c57
parent6eb9e0f5ebb94cccf52ea27aa342001b84c1c8b1
[flang] Don't prematurely resolve subprogram names

Name resolution for subprograms checks whether the name is already
present in the enclosing scope as a generic interface, so that the
case of a generic with the same name as one of its specifics can be
handled.  The particular means by which the enclosing scope is searched
for the name would resolve the name (bind a symbol to it) as a side
effect.  This turns out to be the wrong thing to do when the subprogram
is going to have its symbol created in another scope to cope with its
BIND(C,NAME="name") name, and its Fortran name is already present in the
enclosing scope for a subprogram of the same name but without
BIND(C,NAME="name").

A very long explanation for a one-line fix, sorry.  In short, change
the code to look up the name but not resolve it at that point.

Differential Revision: https://reviews.llvm.org/D126149
flang/lib/Semantics/resolve-names.cpp