[PATCH] D113706: [flang] Allow implicit procedure pointers to associate with explicit procedures
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 09:51:46 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f11944652de: [flang] Allow implicit procedure pointers to associate with explicit procedures (authored by PeteSteinfeld).
Changed prior to commit:
https://reviews.llvm.org/D113706?vs=386848&id=387303#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113706/new/
https://reviews.llvm.org/D113706
Files:
flang/lib/Evaluate/characteristics.cpp
flang/lib/Evaluate/tools.cpp
flang/test/Semantics/assign03.f90
flang/test/Semantics/associated.f90
Index: flang/test/Semantics/associated.f90
===================================================================
--- flang/test/Semantics/associated.f90
+++ flang/test/Semantics/associated.f90
@@ -36,6 +36,10 @@
integer :: i
end subroutine subr
+ subroutine subrCannotBeCalledfromImplicit(i)
+ integer :: i(:)
+ end subroutine subrCannotBeCalledfromImplicit
+
subroutine test()
integer :: intVar
integer, target :: targetIntVar1
@@ -145,9 +149,9 @@
intProcPointer1 => subProc
!ERROR: Function pointer 'intprocpointer1' may not be associated with subroutine designator 'subproc'
lvar = associated(intProcPointer1, subProc)
- !ERROR: Procedure pointer 'implicitprocpointer' with implicit interface may not be associated with procedure designator 'subr' with explicit interface
- implicitProcPointer => subr
- !ERROR: Procedure pointer 'implicitprocpointer' with implicit interface may not be associated with procedure designator 'subr' with explicit interface
- lvar = associated(implicitProcPointer, subr)
+ implicitProcPointer => subr ! OK for an implicit point to point to an explicit proc
+ lvar = associated(implicitProcPointer, subr) ! OK
+ !ERROR: Procedure pointer 'implicitprocpointer' with implicit interface may not be associated with procedure designator 'subrcannotbecalledfromimplicit' with explicit interface that cannot be called via an implicit interface
+ lvar = associated(implicitProcPointer, subrCannotBeCalledFromImplicit)
end subroutine test
end subroutine assoc
Index: flang/test/Semantics/assign03.f90
===================================================================
--- flang/test/Semantics/assign03.f90
+++ flang/test/Semantics/assign03.f90
@@ -178,8 +178,7 @@
external :: s_external
!ERROR: Procedure pointer 'p' with explicit interface may not be associated with procedure designator 's_external' with implicit interface
p => s_external
- !ERROR: Procedure pointer 'r' with implicit interface may not be associated with procedure designator 's_module' with explicit interface
- r => s_module
+ r => s_module ! OK for a pointer with implicit interface to be associated with a procedure with an explicit interface. See 10.2.2.4 (3)
end
! 10.2.2.4(5)
Index: flang/lib/Evaluate/tools.cpp
===================================================================
--- flang/lib/Evaluate/tools.cpp
+++ flang/lib/Evaluate/tools.cpp
@@ -954,12 +954,17 @@
" designator '%s'"_err_en_US;
} else if (lhsProcedure->HasExplicitInterface() &&
!rhsProcedure->HasExplicitInterface()) {
+ // Section 10.2.2.4, paragraph 3 prohibits associating a procedure pointer
+ // with an explicit interface with a procedure with an implicit interface
msg = "Procedure %s with explicit interface may not be associated with"
" procedure designator '%s' with implicit interface"_err_en_US;
} else if (!lhsProcedure->HasExplicitInterface() &&
rhsProcedure->HasExplicitInterface()) {
- msg = "Procedure %s with implicit interface may not be associated with"
- " procedure designator '%s' with explicit interface"_err_en_US;
+ if (!rhsProcedure->CanBeCalledViaImplicitInterface()) {
+ msg = "Procedure %s with implicit interface may not be associated "
+ "with procedure designator '%s' with explicit interface that "
+ "cannot be called via an implicit interface"_err_en_US;
+ }
} else {
msg = "Procedure %s associated with incompatible procedure"
" designator '%s'"_err_en_US;
Index: flang/lib/Evaluate/characteristics.cpp
===================================================================
--- flang/lib/Evaluate/characteristics.cpp
+++ flang/lib/Evaluate/characteristics.cpp
@@ -833,6 +833,7 @@
}
bool Procedure::CanBeCalledViaImplicitInterface() const {
+ // TODO: Pass back information on why we return false
if (attrs.test(Attr::Elemental) || attrs.test(Attr::BindC)) {
return false; // 15.4.2.2(5,6)
} else if (IsFunction() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113706.387303.patch
Type: text/x-patch
Size: 4058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/d579e1bd/attachment.bin>
More information about the llvm-commits
mailing list