[flang-commits] [PATCH] D136989: [flang] Correct a predicate around a semantic check

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Oct 28 14:42:38 PDT 2022


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

When a dummy argument is a procedure pointer without INTENT(IN),
any actual argument must also be a procedure pointer, whether the
dummy procedure pointer's interface is explicit or not.


https://reviews.llvm.org/D136989

Files:
  flang/lib/Semantics/check-call.cpp
  flang/test/Semantics/call09.f90


Index: flang/test/Semantics/call09.f90
===================================================================
--- flang/test/Semantics/call09.f90
+++ flang/test/Semantics/call09.f90
@@ -1,7 +1,7 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
 ! Test 15.5.2.9(2,3,5) dummy procedure requirements
 ! C843
-!   An entity with the INTENT attribute shall be a dummy data object or a 
+!   An entity with the INTENT attribute shall be a dummy data object or a
 !   dummy procedure pointer.
 
 module m
@@ -22,6 +22,9 @@
   subroutine s02(p)
     procedure(realfunc), pointer :: p
   end subroutine
+  subroutine s02b(p)
+    procedure(real), pointer :: p
+  end subroutine
   subroutine s03(p)
     procedure(realfunc) :: p
   end subroutine
@@ -90,6 +93,16 @@
     call s05(null())
     !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
     call s02(sin)
+    !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
+    call s02b(realfunc)
+    call s02b(p) ! ok
+    !ERROR: Actual argument function associated with procedure dummy argument 'p=' has incompatible result type
+    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(null())
+    !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
+    call s02b(sin)
   end subroutine
 
   subroutine callsub(s)
Index: flang/lib/Semantics/check-call.cpp
===================================================================
--- flang/lib/Semantics/check-call.cpp
+++ flang/lib/Semantics/check-call.cpp
@@ -658,8 +658,7 @@
             dummyName);
       }
     }
-    if (interface.HasExplicitInterface() && dummyIsPointer &&
-        dummy.intent != common::Intent::In) {
+    if (dummyIsPointer && dummy.intent != common::Intent::In) {
       const Symbol *last{GetLastSymbol(*expr)};
       if (!(last && IsProcedurePointer(*last)) &&
           !(dummy.intent == common::Intent::Default &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136989.471658.patch
Type: text/x-patch
Size: 2147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221028/d7892a7b/attachment-0001.bin>


More information about the flang-commits mailing list