1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Pointer assignment constraints 10.2.2.2
17 !ERROR: 'p1' may not have both the POINTER and TARGET attributes
18 real, pointer :: p1
, p3
20 !ERROR: 'sin' may not have both the POINTER and INTRINSIC attributes
21 real, intrinsic, pointer :: sin
23 !ERROR: 'p2' may not have both the POINTER and ALLOCATABLE attributes
25 !ERROR: 'a' may not have the POINTER attribute because it is a coarray
26 real, pointer :: a(:)[*]
36 !ERROR: Target type REAL(8) is not compatible with pointer type REAL(4)
38 !ERROR: Target type LOGICAL(4) is not compatible with pointer type REAL(4)
44 real, target
:: r1(4), r2(4,4)
47 !ERROR: Pointer has rank 1 but target has rank 2
53 type(t(1)), target
:: x1
54 type(t(2)), target
:: x2
55 type(t(1)), pointer :: p
57 !ERROR: Target type t(k=2_4) is not compatible with pointer type t(k=1_4)
64 type(t(1)), pointer :: p1
65 type(t2
), pointer :: p2
66 class(*), pointer :: p3
68 p2
=> x
! OK - not extensible
69 p3
=> x
! OK - unlimited polymorphic
70 !ERROR: Pointer type must be unlimited polymorphic or non-extensible derived type when target is unlimited polymorphic
72 !ERROR: Pointer type must be unlimited polymorphic or non-extensible derived type when target is unlimited polymorphic
79 real, target
, volatile :: y
[*]
81 real, pointer, volatile :: q
83 !ERROR: Pointer must be VOLATILE when target is a VOLATILE coarray
85 !ERROR: Pointer may not be VOLATILE when target is a non-VOLATILE coarray
99 !ERROR: 'p' is not a pointer
102 !ERROR: 'b' is not a pointer
106 !C1025 (R1037) The expr shall be a designator that designates a
107 !variable with either the TARGET or POINTER attribute and is not
108 !an array section with a vector subscript, or it shall be a reference
109 !to a function that returns a data pointer.
117 !ERROR: In assignment to object pointer 'b', the target 'd' is not an object with POINTER or TARGET attributes
125 real, pointer :: p(:)
126 !ERROR: An array section with a vector subscript may not be a pointer target
135 !ERROR: pointer 'p' is associated with the result of a reference to function 'f2' that is a not a pointer
148 ! C1026 (R1037) A data-target shall not be a coindexed object.
152 !ERROR: A coindexed object may not be a pointer target
164 type(t1
), pointer :: c
172 type(t2
), target
:: x
174 !OK: x has TARGET attribute
176 !OK: c has POINTER attribute
178 !ERROR: In assignment to object pointer 'p', the target 'y%b%a' is not an object with POINTER or TARGET attributes
181 !OK: x has TARGET attribute
185 !OK: c has POINTER attribute
189 !ERROR: In assignment to object pointer 'p', the target 'z%a' is not an object with POINTER or TARGET attributes
192 associate(z
=> y
%b
%a
)
193 !ERROR: In assignment to object pointer 'p', the target 'z' is not an object with POINTER or TARGET attributes