[flang-commits] [flang] 5be7f8a - [flang] Catch attempt to misuse an abstract procedure in a generic interface
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Mar 2 09:46:28 PST 2023
Author: Peter Klausler
Date: 2023-03-02T09:43:00-08:00
New Revision: 5be7f8a666daee086042da0650b595a0938e3da2
URL: https://github.com/llvm/llvm-project/commit/5be7f8a666daee086042da0650b595a0938e3da2
DIFF: https://github.com/llvm/llvm-project/commit/5be7f8a666daee086042da0650b595a0938e3da2.diff
LOG: [flang] Catch attempt to misuse an abstract procedure in a generic interface
A procedure defined in an ABSTRACT INTERFACE may not appear as
a specific procedure in a generic interface.
Differential Revision: https://reviews.llvm.org/D145102
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/generic02.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 8321bbc08b7a..8c38d0f59b6e 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1374,6 +1374,14 @@ void CheckHelper::CheckSpecificsAreDistinguishable(
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
index e4f7fe671aae..551b897470ce 100644
--- 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
More information about the flang-commits
mailing list