1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
! RUN: %python %S/test_errors.py %s %flang_fc1
! Miscellaneous constraint and requirement checking on intrinsics
program test_size
real :: scalar
real, dimension(5, 5) :: array
call test(array, array)
contains
subroutine test(arg, assumedRank)
real, dimension(5, *) :: arg
real, dimension(..) :: assumedRank
!ERROR: A dim= argument is required for 'size' when the array is assumed-size
print *, size(arg)
!ERROR: missing mandatory 'dim=' argument
print *, ubound(arg)
!ERROR: The 'source=' argument to the intrinsic function 'shape' may not be assumed-size
print *, shape(arg)
!ERROR: The 'harvest=' argument to the intrinsic procedure 'random_number' may not be assumed-size
call random_number(arg)
!ERROR: missing mandatory 'dim=' argument
print *, lbound(scalar)
!ERROR: 'array=' argument has unacceptable rank 0
print *, size(scalar)
!ERROR: missing mandatory 'dim=' argument
print *, ubound(scalar)
!ERROR: DIM=0 dimension must be positive
print *, lbound(arg, 0)
!ERROR: DIM=0 dimension must be positive
print *, lbound(assumedRank, 0)
!ERROR: DIM=666 dimension is too large for any array (maximum rank 15)
print *, lbound(assumedRank, 666)
!ERROR: DIM=0 dimension must be positive
print *, ubound(arg, 0)
!ERROR: DIM=2 dimension is out of range for rank-2 assumed-size array
print *, ubound(arg, 2)
!ERROR: DIM=0 dimension must be positive
print *, ubound(assumedRank, 0)
!ERROR: DIM=666 dimension is too large for any array (maximum rank 15)
print *, ubound(assumedRank, 666)
select rank(assumedRank)
rank(1)
!ERROR: DIM=2 dimension is out of range for rank-1 array
print *, lbound(assumedRank, dim=2)
!ERROR: DIM=2 dimension is out of range for rank-1 array
print *, ubound(assumedRank, dim=2)
end select
! But these cases are fine:
print *, size(arg, dim=1)
print *, ubound(arg, dim=1)
print *, lbound(arg)
print *, size(array)
print *, ubound(array)
print *, lbound(array)
print *, size(arg(:,1))
print *, ubound(arg(:,1))
print *, shape(scalar)
print *, shape(arg(:,1))
print *, lbound(assumedRank, dim=2) ! can't check until run time
print *, ubound(assumedRank, dim=2)
select rank(assumedRank)
rank(3)
print *, lbound(assumedRank, dim=2)
print *, ubound(assumedRank, dim=2)
rank default
print *, lbound(assumedRank, dim=2)
print *, ubound(assumedRank, dim=2)
end select
end subroutine
end
|