Skip to content

Commit 510285c

Browse files
authored
[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.
1 parent b53bdc6 commit 510285c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
690690
}
691691
}
692692
if (actualLastObject && actualLastObject->IsCoarray() &&
693-
IsAllocatable(*actualLastSymbol) && dummy.intent == common::Intent::Out &&
693+
dummy.attrs.test(characteristics::DummyDataObject::Attr::Allocatable) &&
694+
dummy.intent == common::Intent::Out &&
694695
!(intrinsic &&
695696
evaluate::AcceptsIntentOutAllocatableCoarray(
696697
intrinsic->name))) { // C846

flang/test/Semantics/call04.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ module m
2121
subroutine s01a(x)
2222
real, allocatable, intent(out) :: x(:)
2323
end subroutine
24+
subroutine s01c(x)
25+
real, intent(out) :: x(:)
26+
end subroutine
2427
subroutine s01b ! C846 - can only be caught at a call via explicit interface
2528
!ERROR: ALLOCATABLE coarray 'coarray' may not be associated with INTENT(OUT) dummy argument 'x='
2629
!ERROR: ALLOCATABLE dummy argument 'x=' has corank 0 but actual argument has corank 1
2730
call s01a(coarray)
31+
call s01c(coarray) ! ok, dummy is not allocatable
2832
end subroutine
2933

3034
subroutine s02(x) ! C846

0 commit comments

Comments
 (0)