161 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12program test3 real, allocatable :: a0, a1(:)4 real, pointer :: p0, p1(:)5 real, target :: t0, t1(1)6 contains7 subroutine allocatables(a)8 real, allocatable :: a(..)9 select rank(a)10 rank (0)11 allocate(a) ! ok12 deallocate(a) ! ok13 allocate(a, source=a0) ! ok14 allocate(a, mold=p0) ! ok15 a = 1. ! ok16 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar REAL(4) and rank 1 array of REAL(4)17 a = [1.]18 !ERROR: If SOURCE appears, the related expression must be scalar or have the same rank as each allocatable object in ALLOCATE19 allocate(a, source=a1)20 allocate(a, mold=p1) ! ok, mold= ignored21 rank (1)22 allocate(a(1)) ! ok23 deallocate(a) ! ok24 a = 1. ! ok25 a = [1.] ! ok26 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD27 allocate(a, source=a0)28 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD29 allocate(a, mold=p0)30 allocate(a, source=a1) ! ok31 allocate(a, mold=p1) ! ok32 rank (2)33 allocate(a(1,1)) ! ok34 deallocate(a) ! ok35 a = 1. ! ok36 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 2 array of REAL(4) and rank 1 array of REAL(4)37 a = [1.]38 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD39 allocate(a, source=a0)40 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD41 allocate(a, mold=p0)42 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD43 allocate(a, source=a1)44 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD45 allocate(a, mold=p1)46 !ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE47 rank (*)48 !ERROR: Whole assumed-size array 'a' may not appear here without subscripts49 allocate(a)50 !ERROR: Whole assumed-size array 'a' may not appear here without subscripts51 deallocate(a)52 !ERROR: Whole assumed-size array 'a' may not appear here without subscripts53 a = 1.54 rank default55 !ERROR: An assumed-rank dummy argument may not appear in an ALLOCATE statement56 allocate(a)57 deallocate(a)58 !ERROR: An assumed-rank dummy argument is not allowed in an assignment statement59 !ERROR: An assumed-rank dummy argument is not allowed as an operand here60 a = a + 1.61 end select62 ! Test nested associations63 select rank(a)64 rank default65 select rank(a)66 rank default67 select rank(a)68 rank (0)69 allocate(a) ! ok70 deallocate(a) ! ok71 rank (1)72 allocate(a(1)) ! ok73 deallocate(a) ! ok74 end select75 end select76 end select77 end78 subroutine pointers(p)79 real, pointer :: p(..)80 select rank(p)81 rank (0)82 allocate(p) ! ok83 deallocate(p) ! ok84 allocate(p, source=a0) ! ok85 allocate(p, mold=p0) ! ok86 !ERROR: If SOURCE appears, the related expression must be scalar or have the same rank as each allocatable object in ALLOCATE87 allocate(p, source=a1)88 allocate(p, mold=p1) ! ok, mold ignored89 p => t0 ! ok90 !ERROR: Pointer has rank 0 but target has rank 191 p => t192 rank (1)93 allocate(p(1)) ! ok94 deallocate(p) ! ok95 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD96 allocate(p, source=a0)97 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD98 allocate(p, mold=p0)99 allocate(p, source=a1) ! ok100 allocate(p, mold=p1) ! ok101 !ERROR: Pointer has rank 1 but target has rank 0102 p => t0103 p => t1 ! ok104 rank (2)105 allocate(p(1,1)) ! ok106 deallocate(p) ! ok107 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD108 allocate(p, source=a0)109 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD110 allocate(p, mold=p0)111 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD112 allocate(p, source=a1)113 !ERROR: Arrays in ALLOCATE must have a shape specification or an expression of the same rank must appear in SOURCE or MOLD114 allocate(p, mold=p1)115 !ERROR: Pointer has rank 2 but target has rank 0116 p => t0117 !ERROR: Pointer has rank 2 but target has rank 1118 p => t1119 !ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE120 rank (*)121 !ERROR: Whole assumed-size array 'p' may not appear here without subscripts122 allocate(p)123 !ERROR: Whole assumed-size array 'p' may not appear here without subscripts124 deallocate(p)125 rank default126 !ERROR: An assumed-rank dummy argument may not appear in an ALLOCATE statement127 allocate(p)128 deallocate(p)129 !ERROR: The left-hand side of a pointer assignment must not be an assumed-rank dummy argument130 !ERROR: pointer 'p' associated with object 't0' with incompatible type or shape131 p => t0132 !ERROR: The left-hand side of a pointer assignment must not be an assumed-rank dummy argument133 !ERROR: pointer 'p' associated with object 't1' with incompatible type or shape134 p => t1135 end select136 end137 subroutine undefinable(p)138 real, pointer, intent(in) :: p(..)139 real, target :: t140 select rank(p)141 rank (0)142 !ERROR: The left-hand side of a pointer assignment is not definable143 !BECAUSE: 'p' is an INTENT(IN) dummy argument144 p => t145 !ERROR: Name in DEALLOCATE statement is not definable146 !BECAUSE: 'p' is an INTENT(IN) dummy argument147 deallocate(p)148 !ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE149 rank (*)150 !ERROR: Whole assumed-size array 'p' may not appear here without subscripts151 !ERROR: Name in DEALLOCATE statement is not definable152 !BECAUSE: 'p' is an INTENT(IN) dummy argument153 deallocate(p)154 rank default155 !ERROR: Name in DEALLOCATE statement is not definable156 !BECAUSE: 'p' is an INTENT(IN) dummy argument157 deallocate(p)158 end select159 end160end161