Skip to content

Commit 36caa8f

Browse files
authored
[flang] Fix crash on SMP with dummy procedure (llvm#124663)
When a separate module procedure is defined with MODULE PROCEDURE, the compiler crashes if there is a dummy procedure in the interface defined with only a result type. This is due to the type already having been defined on the ProcEntityDetails symbol as part of earlier wholesale symbol duplication. Adjust the code to not define the result type of the ProcEntityDetails if it is already present, but to verify that it is the same type instead. Fixes llvm#124487.
1 parent 8d8a821 commit 36caa8f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

flang/lib/Semantics/resolve-names-utils.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,11 @@ void SymbolMapper::MapSymbolExprs(Symbol &symbol) {
762762
proc.set_procInterfaces(
763763
*mappedSymbol, BypassGeneric(mappedSymbol->GetUltimate()));
764764
} else if (const DeclTypeSpec * mappedType{MapType(proc.type())}) {
765-
proc.set_type(*mappedType);
765+
if (proc.type()) {
766+
CHECK(*proc.type() == *mappedType);
767+
} else {
768+
proc.set_type(*mappedType);
769+
}
766770
}
767771
if (proc.init()) {
768772
if (const Symbol * mapped{MapSymbol(*proc.init())}) {

flang/test/Semantics/bug124487.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck --allow-empty %s
2+
!CHECK-NOT: error:
3+
module m
4+
interface
5+
module subroutine smp(x)
6+
character, external :: x
7+
end
8+
end interface
9+
end
10+
submodule (m) sm
11+
contains
12+
module procedure smp ! crashes here
13+
end
14+
end

0 commit comments

Comments
 (0)