diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -1374,6 +1374,14 @@ GenericKind kind{details.kind()}; DistinguishabilityHelper helper{context_}; for (const Symbol &specific : details.specificProcs()) { + if (specific.attrs().test(Attr::ABSTRACT)) { + if (auto *msg{messages_.Say(generic.name(), + "Generic interface '%s' must not use abstract interface '%s' as a specific procedure"_err_en_US, + generic.name(), specific.name())}) { + msg->Attach( + specific.name(), "Definition of '%s'"_en_US, specific.name()); + } + } if (const Procedure *procedure{Characterize(specific)}) { if (procedure->HasExplicitInterface()) { helper.Add(generic, kind, specific, *procedure); diff --git a/flang/test/Semantics/generic02.f90 b/flang/test/Semantics/generic02.f90 --- a/flang/test/Semantics/generic02.f90 +++ b/flang/test/Semantics/generic02.f90 @@ -1,10 +1,16 @@ ! RUN: %python %S/test_errors.py %s %flang_fc1 program test + !ERROR: Generic interface 'generic' must not use abstract interface 'abstract' as a specific procedure interface generic subroutine explicit(n) integer, intent(in) :: n end subroutine procedure implicit + procedure abstract + end interface + abstract interface + subroutine abstract + end subroutine end interface !ERROR: Specific procedure 'implicit' of generic interface 'generic' must have an explicit interface external implicit