Skip to content

Commit d4fd0a7

Browse files
authored
[flang] Fix symbol on module subroutine name with same name as generic (llvm#67678)
When a MODULE SUBROUTINE or MODULE FUNCTION is implemented in the same scope as its interface and appears in a generic with the same name, the parse::Name of the implementation was not correctly reset and remained the SubprogramNameDetails symbol after semantics, causing a crash in lowering that picks up the procedure symbols on the parser names. Reset the parser::Name symbol before the new symbol is created.
1 parent d6ae4bd commit d4fd0a7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,6 +4111,7 @@ bool SubprogramVisitor::BeginSubprogram(const parser::Name &name,
41114111
if (GenericDetails *
41124112
generic{DEREF(FindSymbol(name)).detailsIf<GenericDetails>()}) {
41134113
generic->clear_specific();
4114+
name.symbol = nullptr;
41144115
} else {
41154116
EraseSymbol(name);
41164117
}

flang/test/Semantics/symbol28.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module subroutine s2 (j)
1414
end subroutine
1515
end interface
1616
contains
17-
!DEF: /m1/s MODULE (Subroutine) SubprogramName
17+
!DEF: /m1/s MODULE (Subroutine) Subprogram
1818
module subroutine s
1919
end subroutine
2020
!REF: /m1/s2

0 commit comments

Comments
 (0)