1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Pointer assignment constraints 10.2.2.2
16 !ERROR: 'p1' may not have both the POINTER and TARGET attributes
17 real, pointer :: p1
, p3
18 !ERROR: 'p2' may not have both the POINTER and ALLOCATABLE attributes
20 !ERROR: 'sin' may not have both the POINTER and INTRINSIC attributes
21 real, intrinsic, pointer :: sin
24 !ERROR: 'a' may not have the POINTER attribute because it is a coarray
25 real, pointer :: a(:)[*]
35 !ERROR: Target type REAL(8) is not compatible with pointer type REAL(4)
37 !ERROR: Target type LOGICAL(4) is not compatible with pointer type REAL(4)
43 real, target
:: r1(4), r2(4,4)
46 !ERROR: Pointer has rank 1 but target has rank 2
52 type(t(1)), target
:: x1
53 type(t(2)), target
:: x2
54 type(t(1)), pointer :: p
56 !ERROR: Target type t(k=2_4) is not compatible with pointer type t(k=1_4)
63 type(t(1)), pointer :: p1
64 type(t2
), pointer :: p2
65 class(*), pointer :: p3
67 p2
=> x
! OK - not extensible
68 p3
=> x
! OK - unlimited polymorphic
69 !ERROR: Pointer type must be unlimited polymorphic or non-extensible derived type when target is unlimited polymorphic
71 !ERROR: Pointer type must be unlimited polymorphic or non-extensible derived type when target is unlimited polymorphic
78 real, target
, volatile :: y
[*]
80 real, pointer, volatile :: q
82 !ERROR: Pointer must be VOLATILE when target is a VOLATILE coarray
84 !ERROR: Pointer may not be VOLATILE when target is a non-VOLATILE coarray
98 !ERROR: The left-hand side of a pointer assignment is not definable
99 !BECAUSE: 'p' is not a pointer
102 !ERROR: The left-hand side of a pointer assignment is not definable
103 !BECAUSE: 'b' is not a pointer
107 !C1025 (R1037) The expr shall be a designator that designates a
108 !variable with either the TARGET or POINTER attribute and is not
109 !an array section with a vector subscript, or it shall be a reference
110 !to a function that returns a data pointer.
118 !ERROR: In assignment to object pointer 'b', the target 'd' is not an object with POINTER or TARGET attributes
126 real, pointer :: p(:)
127 !ERROR: An array section with a vector subscript may not be a pointer target
136 !ERROR: pointer 'p' is associated with the result of a reference to function 'f2' that is a not a pointer
149 ! C1026 (R1037) A data-target shall not be a coindexed object.
153 !ERROR: A coindexed object may not be a pointer target
165 type(t1
), pointer :: c
173 type(t2
), target
:: x
175 !OK: x has TARGET attribute
177 !OK: c has POINTER attribute
179 !ERROR: In assignment to object pointer 'p', the target 'y%b%a' is not an object with POINTER or TARGET attributes
182 !OK: x has TARGET attribute
186 !OK: c has POINTER attribute
190 !ERROR: In assignment to object pointer 'p', the target 'z%a' is not an object with POINTER or TARGET attributes
193 associate(z
=> y
%b
%a
)
194 !ERROR: In assignment to object pointer 'p', the target 'z' is not an object with POINTER or TARGET attributes