[flang-commits] [flang] 510285c - [flang] Fix allocatable coarray INTENT(OUT) check (#121528)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 8 13:15:00 PST 2025


Author: Peter Klausler
Date: 2025-01-08T13:14:57-08:00
New Revision: 510285cd67a7f7626ba6d6733207480ca5b2b469

URL: https://github.com/llvm/llvm-project/commit/510285cd67a7f7626ba6d6733207480ca5b2b469
DIFF: https://github.com/llvm/llvm-project/commit/510285cd67a7f7626ba6d6733207480ca5b2b469.diff

LOG: [flang] Fix allocatable coarray INTENT(OUT) check (#121528)

An allocatable coarray being argument associated with a non-allocatable
INTENT(OUT) dummy argument is not an error.

Added: 
    

Modified: 
    flang/lib/Semantics/check-call.cpp
    flang/test/Semantics/call04.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 8631789b9f5263..a343046570f2fc 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -690,7 +690,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
     }
   }
   if (actualLastObject && actualLastObject->IsCoarray() &&
-      IsAllocatable(*actualLastSymbol) && dummy.intent == common::Intent::Out &&
+      dummy.attrs.test(characteristics::DummyDataObject::Attr::Allocatable) &&
+      dummy.intent == common::Intent::Out &&
       !(intrinsic &&
           evaluate::AcceptsIntentOutAllocatableCoarray(
               intrinsic->name))) { // C846

diff  --git a/flang/test/Semantics/call04.f90 b/flang/test/Semantics/call04.f90
index 6877f9c9fa939e..9be579fb696c03 100644
--- a/flang/test/Semantics/call04.f90
+++ b/flang/test/Semantics/call04.f90
@@ -21,10 +21,14 @@ module m
   subroutine s01a(x)
     real, allocatable, intent(out) :: x(:)
   end subroutine
+  subroutine s01c(x)
+    real, intent(out) :: x(:)
+  end subroutine
   subroutine s01b ! C846 - can only be caught at a call via explicit interface
     !ERROR: ALLOCATABLE coarray 'coarray' may not be associated with INTENT(OUT) dummy argument 'x='
     !ERROR: ALLOCATABLE dummy argument 'x=' has corank 0 but actual argument has corank 1
     call s01a(coarray)
+    call s01c(coarray) ! ok, dummy is not allocatable
   end subroutine
 
   subroutine s02(x) ! C846


        


More information about the flang-commits mailing list