Skip to content

Commit cd2a8df

Browse files
committed
[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
1 parent 6eb9e0f commit cd2a8df

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,8 @@ void SubprogramVisitor::PushBlockDataScope(const parser::Name &name) {
37063706

37073707
// If name is a generic, return specific subprogram with the same name.
37083708
Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
3709-
if (auto *symbol{FindSymbol(name)}) {
3709+
// Search for the name but don't resolve it
3710+
if (auto *symbol{currScope().FindSymbol(name.source)}) {
37103711
if (auto *details{symbol->detailsIf<GenericDetails>()}) {
37113712
// found generic, want subprogram
37123713
auto *specific{details->specific()};

0 commit comments

Comments
 (0)