Skip to content

Commit d016068

Browse files
committed
[flang] Fix crash resolving interface procedure type.
When generic interface name shadows specific, bypass to specific procedure while resolving its type.
1 parent 4e71976 commit d016068

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,9 @@ inline const DeclTypeSpec *Symbol::GetTypeImpl(int depth) const {
11261126
[&](const HostAssocDetails &x) {
11271127
return x.symbol().GetTypeImpl(depth);
11281128
},
1129+
[&](const GenericDetails &x) {
1130+
return x.specific() ? x.specific()->GetTypeImpl(depth) : nullptr;
1131+
},
11291132
[](const auto &) -> const DeclTypeSpec * { return nullptr; },
11301133
},
11311134
details_);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! these modules must be read from module files
2+
module m1
3+
interface f ! reference must be to generic
4+
module procedure f ! must have same name as generic interface
5+
end interface
6+
contains
7+
character function f() ! must be character
8+
f = 'q'
9+
end
10+
end
11+
module m2
12+
use m1
13+
end
14+
module m3
15+
use m2 ! must be m2, not m1
16+
contains
17+
subroutine mustExist() ! not called, but must exist
18+
character x
19+
x = f()
20+
end
21+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
! Check that expected code produced with no crash.
2+
subroutine reproducer()
3+
use m2
4+
use m3
5+
character x
6+
x = f()
7+
end
8+
9+
! RUN: %flang_fc1 -fsyntax-only %S/Inputs/generic-shadows-specific-a.f90
10+
! RUN: bbc -emit-fir -o - %s | FileCheck %s
11+
12+
! CHECK-LABEL: func.func @_QPreproducer
13+
! CHECK: fir.call @_QMm1Pf

0 commit comments

Comments
 (0)