diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -3248,7 +3248,12 @@ 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); } diff --git a/flang/test/Semantics/resolve18.f90 b/flang/test/Semantics/resolve18.f90 --- a/flang/test/Semantics/resolve18.f90 +++ b/flang/test/Semantics/resolve18.f90 @@ -63,6 +63,15 @@ 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