1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Pointer assignment constraints 10.2.2.2 (see also assign02.f90)
12 procedure(s
), pointer, nopass
:: p
18 type(t
), allocatable
:: a(:)
19 type(t
), allocatable
:: b
[:]
21 !ERROR: Procedure pointer may not be a coindexed object
28 !ERROR: In assignment to object pointer 'q', the target 's' is a procedure designator
34 a
%p
=> f() ! OK: pointer-valued function
35 !ERROR: Subroutine pointer 'p' may not be associated with function designator 'f'
39 procedure(s
), pointer :: f
44 ! C1030 and 10.2.2.4 - procedure names as target of procedure pointer
45 subroutine s4(s_dummy
)
46 procedure(s
) :: s_dummy
47 procedure(s
), pointer :: p
, q
48 procedure(), pointer :: r
50 external :: s_external
57 subroutine s_internal(i
)
61 subroutine s_module(i
)
67 procedure(f_pure
), pointer :: p_pure
68 procedure(f_impure
), pointer :: p_impure
69 !ERROR: Procedure pointer 'p_elemental' may not be ELEMENTAL
70 procedure(f_elemental
), pointer :: p_elemental
74 !ERROR: PURE procedure pointer 'p_pure' may not be associated with non-PURE procedure designator 'f_impure'
77 pure
integer function f_pure()
80 integer function f_impure()
83 elemental
integer function f_elemental()
90 procedure(s
), pointer :: p
, q
91 procedure(), pointer :: r
92 external :: s_external
93 !ERROR: Procedure pointer 'p' with explicit interface may not be associated with procedure designator 's_external' with implicit interface
95 !ERROR: Procedure pointer 'r' with implicit interface may not be associated with procedure designator 's_module' with explicit interface
101 procedure(real) :: f_external
102 external :: s_external
103 procedure(), pointer :: p_s
104 procedure(real), pointer :: p_f
107 !ERROR: Subroutine pointer 'p_s' may not be associated with function designator 'f_external'
109 !ERROR: Function pointer 'p_f' may not be associated with subroutine designator 's_external'
115 real, target
:: x(10, 10)
116 real, pointer :: p(:, :)
118 !ERROR: Pointer 'p' has rank 2 but the number of bounds specified is 1
124 real, target
:: x(10, 10), y(100)
125 real, pointer :: p(:, :)
127 !ERROR: Pointer 'p' has rank 2 but the number of bounds specified is 1
130 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
131 p(1:5,1:5) => x(1:10,::2)
133 !ERROR: Pointer bounds require 25 elements but target has only 20
134 p(1:5,1:5) => x(:,1:2)
135 !OK - rhs has rank 1 and enough elements
136 p(1:5,1:5) => y(1:100:2)
140 integer, pointer :: p(:)
146 type(t
), target
:: y(10,10)
150 p(1:1) => x
%b
! We treat scalars as simply contiguous
152 p(1:1) => y(1,1)%a(1,1)
153 p(1:1) => y(:,1)%a(1,1) ! Rank 1 RHS
154 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
155 p(1:4) => x
%a(::2,::2)
156 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
158 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
159 p(1:100) => y(:,:)%a(1,1)
160 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
161 !ERROR: An array section with a vector subscript may not be a pointer target
166 complex, target
:: x(10,10)
167 complex, pointer :: p(:)
168 real, pointer :: q(:)
171 !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous
172 q(1:100) => x(:,:)%re
175 ! Check is_contiguous, which is usually the same as when pointer bounds
176 ! remapping is used. If it's not simply contiguous it's not constant so
177 ! an error is reported.
179 integer, pointer :: p(:)
185 type(t
), target
:: y(10,10)
187 logical, parameter :: l1
= is_contiguous(x
%a(:,:))
188 logical, parameter :: l2
= is_contiguous(y(1,1)%a(1,1))
189 !ERROR: Must be a constant value
190 logical, parameter :: l3
= is_contiguous(y(:,1)%a(1,1))
191 !ERROR: Must be a constant value
192 logical, parameter :: l4
= is_contiguous(x
%a(:,v
))
193 !ERROR: Must be a constant value
194 logical, parameter :: l5
= is_contiguous(y(v
,1)%a(1,1))
197 integer, intent(inout
) :: b(..)
198 !ERROR: Must be a constant value
199 integer, parameter :: i
= rank(b
)