[PATCH] D93872: [flang] Detect call to abstract interface
Tim Keith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 28 13:24:02 PST 2020
tskeith created this revision.
tskeith added a reviewer: klausler.
tskeith added a project: Flang.
Herald added a subscriber: jdoerfert.
tskeith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
A subroutine call or function reference to an abstract interface is
not legal.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93872
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve20.f90
Index: flang/test/Semantics/resolve20.f90
===================================================================
--- flang/test/Semantics/resolve20.f90
+++ flang/test/Semantics/resolve20.f90
@@ -61,7 +61,18 @@
procedure(proc), deferred :: p1
end type t1
+ abstract interface
+ function f()
+ end function
+ end interface
+
contains
subroutine bar
end subroutine
+ subroutine test
+ !ERROR: Abstract interface 'foo' may not be called
+ call foo()
+ !ERROR: Abstract interface 'f' may not be called
+ x = f()
+ end subroutine
end module
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5879,7 +5879,10 @@
return; // reported error
}
CheckImplicitNoneExternal(name.source, *symbol);
- if (IsProcedure(*symbol) || symbol->has<DerivedTypeDetails>() ||
+ if (symbol->has<SubprogramDetails>() &&
+ symbol->attrs().test(Attr::ABSTRACT)) {
+ Say(name, "Abstract interface '%s' may not be called"_err_en_US);
+ } else if (IsProcedure(*symbol) || symbol->has<DerivedTypeDetails>() ||
symbol->has<ObjectEntityDetails>() ||
symbol->has<AssocEntityDetails>()) {
// Symbols with DerivedTypeDetails, ObjectEntityDetails and
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93872.313888.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201228/9e18b00a/attachment.bin>
More information about the llvm-commits
mailing list