[flang-commits] [flang] [flang] Fix allocatable coarray INTENT(OUT) check (PR #121528)
via flang-commits
flang-commits at lists.llvm.org
Thu Jan 2 15:50:44 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
An allocatable coarray being argument associated with a non-allocatable INTENT(OUT) dummy argument is not an error.
---
Full diff: https://github.com/llvm/llvm-project/pull/121528.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-call.cpp (+2-1)
- (modified) flang/test/Semantics/call04.f90 (+4)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/121528
More information about the flang-commits
mailing list