[flang-commits] [flang] [flang] Fix allocatable coarray INTENT(OUT) check (PR #121528)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 2 15:50:11 PST 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/121528
An allocatable coarray being argument associated with a non-allocatable INTENT(OUT) dummy argument is not an error.
>From 7cd7f39fceffb9178426a78f4d863399a06453f1 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 2 Jan 2025 15:47:55 -0800
Subject: [PATCH] [flang] Fix allocatable coarray INTENT(OUT) check
An allocatable coarray being argument associated with a non-allocatable
INTENT(OUT) dummy argument is not an error.
---
flang/lib/Semantics/check-call.cpp | 3 ++-
flang/test/Semantics/call04.f90 | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 597c280a6df8bc..53a5fd43e425a9 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