Skip to content

Commit d34f5dd

Browse files
authored
[flang] Accept ALLOCATED(ARRAY=assumedRank) (llvm#66233)
The definitions of the ALLOCATED intrinsic in the intrinsics table did not allow for an assumed-rank array.
1 parent 0f65df7 commit d34f5dd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
315315
{"aint", {{"a", SameReal}, MatchingDefaultKIND}, KINDReal},
316316
{"all", {{"mask", SameLogical, Rank::array}, OptionalDIM}, SameLogical,
317317
Rank::dimReduced, IntrinsicClass::transformationalFunction},
318-
{"allocated", {{"array", AnyData, Rank::array}}, DefaultLogical,
319-
Rank::elemental, IntrinsicClass::inquiryFunction},
320318
{"allocated", {{"scalar", AnyData, Rank::scalar}}, DefaultLogical,
321319
Rank::elemental, IntrinsicClass::inquiryFunction},
320+
{"allocated", {{"array", AnyData, Rank::anyOrAssumedRank}}, DefaultLogical,
321+
Rank::elemental, IntrinsicClass::inquiryFunction},
322322
{"anint", {{"a", SameReal}, MatchingDefaultKIND}, KINDReal},
323323
{"any", {{"mask", SameLogical, Rank::array}, OptionalDIM}, SameLogical,
324324
Rank::dimReduced, IntrinsicClass::transformationalFunction},

flang/test/Semantics/allocated.f90

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
! RUN: %python %S/test_errors.py %s %flang_fc1
22
! Tests for the ALLOCATED() intrinsic
3-
subroutine alloc(coarray_alloc, coarray_not_alloc, t2_not_alloc)
3+
subroutine alloc(coarray_alloc, coarray_not_alloc, t2_not_alloc, &
4+
assumedRank)
45

56
interface
67
function return_allocatable()
@@ -30,6 +31,7 @@ function return_allocatable()
3031
real :: coarray_not_alloc(:)[*]
3132

3233
type(t2) :: t2_not_alloc
34+
real, allocatable :: assumedRank(..)
3335

3436

3537
! OK
@@ -42,6 +44,13 @@ function return_allocatable()
4244
print *, allocated(coarray_alloc[2,3])
4345
print *, allocated(t2_not_alloc%coarray_alloc)
4446
print *, allocated(t2_not_alloc%coarray_alloc[2])
47+
print *, allocated(assumedRank)
48+
select rank (assumedRank)
49+
rank (0)
50+
print *, allocated(scalar=assumedRank)
51+
rank default
52+
print *, allocated(array=assumedRank)
53+
end select
4554

4655
!ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
4756
print *, allocated(not_alloc)

0 commit comments

Comments
 (0)