Skip to content

Commit 5727df2

Browse files
committed
[flang] Specific procedures named the same as the generic and a derived type
If you specify a specific procedure of a generic interface that has the same name as both the generic interface and a preceding derived type, the compiler would fail an internal call to CHECK(). I fixed this by testing for this situation when processing specific procedures. I also added a test that will cause the call to CHECK() to fail without this new code. Differential Revision: https://reviews.llvm.org/D99085
1 parent 854de7c commit 5727df2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3248,7 +3248,12 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
32483248
if (!specific) {
32493249
specific =
32503250
&currScope().MakeSymbol(name.source, Attrs{}, SubprogramDetails{});
3251-
details->set_specific(Resolve(name, *specific));
3251+
if (details->derivedType()) {
3252+
// A specific procedure with the same name as a derived type
3253+
SayAlreadyDeclared(name, *details->derivedType());
3254+
} else {
3255+
details->set_specific(Resolve(name, *specific));
3256+
}
32523257
} else if (isGeneric()) {
32533258
SayAlreadyDeclared(name, *specific);
32543259
}

flang/test/Semantics/resolve18.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ module m4b
6363
function foo(x)
6464
end
6565
end
66+
module m4c
67+
type :: foo
68+
end type
69+
interface foo
70+
!ERROR: 'foo' is already declared in this scoping unit
71+
real function foo()
72+
end function foo
73+
end interface foo
74+
end
6675

6776
! Use associating a name that is a generic and a derived type
6877
module m5a

0 commit comments

Comments
 (0)