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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
! RUN: %python %S/test_errors.py %s %flang_fc1
program test
real, allocatable :: a0, a1(:)
real, pointer :: p0, p1(:)
real, target :: t0, t1(1)
contains
subroutine allocatables(a)
real, allocatable :: a(..)
select rank(a)
rank (0)
allocate(a) ! ok
deallocate(a) ! ok
allocate(a, source=a0) ! ok
allocate(a, mold=p0) ! ok
a = 1. ! ok
!ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar REAL(4) and rank 1 array of REAL(4)
a = [1.]
!ERROR: If SOURCE appears, the related expression must be scalar or have the same rank as each allocatable object in ALLOCATE
allocate(a, source=a1)
allocate(a, mold=p1) ! ok, mold= ignored
rank (1)
allocate(a(1)) ! ok
deallocate(a) ! ok
a = 1. ! ok
a = [1.] ! ok
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, source=a0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, mold=p0)
allocate(a, source=a1) ! ok
allocate(a, mold=p1) ! ok
rank (2)
allocate(a(1,1)) ! ok
deallocate(a) ! ok
a = 1. ! ok
!ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 2 array of REAL(4) and rank 1 array of REAL(4)
a = [1.]
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, source=a0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, mold=p0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, source=a1)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(a, mold=p1)
!ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE
rank (*)
!ERROR: Whole assumed-size array 'a' may not appear here without subscripts
allocate(a)
!ERROR: Whole assumed-size array 'a' may not appear here without subscripts
deallocate(a)
!ERROR: Whole assumed-size array 'a' may not appear here without subscripts
a = 1.
rank default
!ERROR: An assumed-rank dummy argument may not appear in an ALLOCATE statement
allocate(a)
deallocate(a)
!ERROR: An assumed-rank dummy argument is not allowed in an assignment statement
!ERROR: An assumed-rank dummy argument is not allowed as an operand here
a = a + 1.
end select
! Test nested associations
select rank(a)
rank default
select rank(a)
rank default
select rank(a)
rank (0)
allocate(a) ! ok
deallocate(a) ! ok
rank (1)
allocate(a(1)) ! ok
deallocate(a) ! ok
end select
end select
end select
end
subroutine pointers(p)
real, pointer :: p(..)
select rank(p)
rank (0)
allocate(p) ! ok
deallocate(p) ! ok
allocate(p, source=a0) ! ok
allocate(p, mold=p0) ! ok
!ERROR: If SOURCE appears, the related expression must be scalar or have the same rank as each allocatable object in ALLOCATE
allocate(p, source=a1)
allocate(p, mold=p1) ! ok, mold ignored
p => t0 ! ok
!ERROR: Pointer has rank 0 but target has rank 1
p => t1
rank (1)
allocate(p(1)) ! ok
deallocate(p) ! ok
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, source=a0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, mold=p0)
allocate(p, source=a1) ! ok
allocate(p, mold=p1) ! ok
!ERROR: Pointer has rank 1 but target has rank 0
p => t0
p => t1 ! ok
rank (2)
allocate(p(1,1)) ! ok
deallocate(p) ! ok
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, source=a0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, mold=p0)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, source=a1)
!ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD
allocate(p, mold=p1)
!ERROR: Pointer has rank 2 but target has rank 0
p => t0
!ERROR: Pointer has rank 2 but target has rank 1
p => t1
!ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE
rank (*)
!ERROR: Whole assumed-size array 'p' may not appear here without subscripts
allocate(p)
!ERROR: Whole assumed-size array 'p' may not appear here without subscripts
deallocate(p)
rank default
!ERROR: An assumed-rank dummy argument may not appear in an ALLOCATE statement
allocate(p)
deallocate(p)
!ERROR: The left-hand side of a pointer assignment must not be an assumed-rank dummy argument
!ERROR: pointer 'p' associated with object 't0' with incompatible type or shape
p => t0
!ERROR: The left-hand side of a pointer assignment must not be an assumed-rank dummy argument
!ERROR: pointer 'p' associated with object 't1' with incompatible type or shape
p => t1
end select
end
subroutine undefinable(p)
real, pointer, intent(in) :: p(..)
real, target :: t
select rank(p)
rank (0)
!ERROR: The left-hand side of a pointer assignment is not definable
!BECAUSE: 'p' is an INTENT(IN) dummy argument
p => t
!ERROR: Name in DEALLOCATE statement is not definable
!BECAUSE: 'p' is an INTENT(IN) dummy argument
deallocate(p)
!ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE
rank (*)
!ERROR: Whole assumed-size array 'p' may not appear here without subscripts
!ERROR: Name in DEALLOCATE statement is not definable
!BECAUSE: 'p' is an INTENT(IN) dummy argument
deallocate(p)
rank default
!ERROR: Name in DEALLOCATE statement is not definable
!BECAUSE: 'p' is an INTENT(IN) dummy argument
deallocate(p)
end select
end
end
|