[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
This commit is contained in:
Peter Steinfeld 2021-03-22 09:04:45 -07:00
parent 854de7c4d0
commit 5727df2714
2 changed files with 15 additions and 1 deletions

View File

@ -3248,7 +3248,12 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
if (!specific) {
specific =
&currScope().MakeSymbol(name.source, Attrs{}, SubprogramDetails{});
details->set_specific(Resolve(name, *specific));
if (details->derivedType()) {
// A specific procedure with the same name as a derived type
SayAlreadyDeclared(name, *details->derivedType());
} else {
details->set_specific(Resolve(name, *specific));
}
} else if (isGeneric()) {
SayAlreadyDeclared(name, *specific);
}

View File

@ -63,6 +63,15 @@ contains
function foo(x)
end
end
module m4c
type :: foo
end type
interface foo
!ERROR: 'foo' is already declared in this scoping unit
real function foo()
end function foo
end interface foo
end
! Use associating a name that is a generic and a derived type
module m5a