File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -885,8 +885,12 @@ auto GetShapeHelper::operator()(const ProcedureRef &call) const -> Result {
885
885
intrinsic->name == " ubound" ) {
886
886
// For LBOUND/UBOUND, these are the array-valued cases (no DIM=)
887
887
if (!call.arguments ().empty () && call.arguments ().front ()) {
888
- return Shape{
889
- MaybeExtentExpr{ExtentExpr{call.arguments ().front ()->Rank ()}}};
888
+ if (IsAssumedRank (*call.arguments ().front ())) {
889
+ return Shape{MaybeExtentExpr{}};
890
+ } else {
891
+ return Shape{
892
+ MaybeExtentExpr{ExtentExpr{call.arguments ().front ()->Rank ()}}};
893
+ }
890
894
}
891
895
} else if (intrinsic->name == " all" || intrinsic->name == " any" ||
892
896
intrinsic->name == " count" || intrinsic->name == " iall" ||
Original file line number Diff line number Diff line change 2
2
! Test comparisons that use the intrinsic SHAPE() as an operand
3
3
program testShape
4
4
contains
5
- subroutine sub1 (arrayDummy )
6
- integer :: arrayDummy(:)
5
+ subroutine sub1 (arrayDummy , assumedRank )
6
+ integer :: arrayDummy(:), assumedRank(..)
7
7
integer , allocatable :: arrayDeferred(:)
8
8
integer :: arrayLocal(2 ) = [88 , 99 ]
9
+ integer , parameter :: aRrs = rank(shape (assumedRank))
10
+ integer (kind= merge (kind (1 ),- 1 ,aRrs == 1 )) :: test_aRrs
9
11
! ERROR: Dimension 1 of left operand has extent 1, but right operand has extent 0
10
12
! ERROR: Dimension 1 of left operand has extent 1, but right operand has extent 0
11
13
if (all (shape (arrayDummy)==shape (8 ))) then
@@ -45,5 +47,9 @@ subroutine sub1(arrayDummy)
45
47
if (all (64 == shape (arrayLocal))) then
46
48
print * , " hello"
47
49
end if
50
+ ! These can't be checked at compilation time
51
+ if (any (shape (assumedRank) == [1 ])) stop
52
+ if (any (lbound (assumedRank) == [1 ,2 ])) stop
53
+ if (any (ubound (assumedRank) == [1 ,2 ,3 ])) stop
48
54
end subroutine sub1
49
55
end program testShape
You can’t perform that action at this time.
0 commit comments