[flang-commits] [flang] [Flang] Allow reference of a function that returns a procedure pointer to be an actual argument corresponding to a procedure pointer dummy. (PR #82824)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Fri Feb 23 12:47:07 PST 2024


https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/82824

>From fadfd4927fff718b34870945ba7823656f2ed1f3 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Fri, 23 Feb 2024 15:12:57 -0500
Subject: [PATCH 1/2] [Flang] Allow reference of a function that returns a
 procedure pointer to be an actual argument corresponding to a procedure
 pointer dummy.

---
 flang/test/Semantics/call09.f90 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/flang/test/Semantics/call09.f90 b/flang/test/Semantics/call09.f90
index b8583ba4a49074..2abea42286ca70 100644
--- a/flang/test/Semantics/call09.f90
+++ b/flang/test/Semantics/call09.f90
@@ -87,8 +87,7 @@ subroutine test1 ! 15.5.2.9(5)
     call s02(p) ! ok
     !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
     call s02(ip)
-    !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
-    call s02(procptr())
+    call s02(procptr()) ! ok
     call s02(null()) ! ok
     !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
     call s05(null())
@@ -99,8 +98,7 @@ subroutine test1 ! 15.5.2.9(5)
     call s02b(p) ! ok
     !ERROR: Actual argument function associated with procedure dummy argument 'p=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
     call s02b(ip)
-    !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
-    call s02b(procptr())
+    call s02b(procptr()) ! ok
     call s02b(null())
     !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
     call s02b(sin)

>From ff44622c771a41087f468a220c0fb2e8091aa677 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Fri, 23 Feb 2024 15:46:56 -0500
Subject: [PATCH 2/2] [Flang] Allow reference of a function that returns a
 procedure pointer to be an actual argument corresponding to a procedure
 pointer dummy.

---
 flang/lib/Semantics/check-call.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index fdf7805beab7ed..9926f23e5241b8 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -1041,7 +1041,7 @@ static void CheckProcedureArg(evaluate::ActualArgument &arg,
     }
     if (dummyIsPointer && dummy.intent != common::Intent::In) {
       const Symbol *last{GetLastSymbol(*expr)};
-      if (last && IsProcedurePointer(*last)) {
+      if (last && IsProcedurePointer(*expr)) {
         if (dummy.intent != common::Intent::Default &&
             IsIntentIn(last->GetUltimate())) { // 19.6.8
           messages.Say(



More information about the flang-commits mailing list