1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test 15.5.2.5 constraints and restrictions for POINTER & ALLOCATABLE
3 ! arguments when both sides of the call have the same attributes.
15 type(t
), pointer :: mp(:), mpmat(:,:)
16 type(t
), allocatable
:: ma(:), mamat(:,:)
17 class(t
), pointer :: pp(:)
18 class(t
), allocatable
:: pa(:)
19 class(t2
), pointer :: pp2(:)
20 class(t2
), allocatable
:: pa2(:)
21 class(*), pointer :: up(:)
22 class(*), allocatable
:: ua(:)
23 !ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, named constant, or external function result
24 type(pdt(*)), pointer :: amp(:)
25 !ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, named constant, or external function result
26 type(pdt(*)), allocatable
:: ama(:)
27 type(pdt(:)), pointer :: dmp(:)
28 type(pdt(:)), allocatable
:: dma(:)
29 type(pdt(1)), pointer :: nmp(:)
30 type(pdt(1)), allocatable
:: nma(:)
35 type(t
), pointer :: x(:)
38 type(t
), allocatable
:: x(:)
41 class(t
), pointer :: x(:)
44 class(t
), allocatable
:: x(:)
47 class(*), pointer :: x(:)
50 class(*), allocatable
:: x(:)
53 type(pdt(*)), pointer :: x(:)
56 type(pdt(*)), allocatable
:: x(:)
59 type(pdt(:)), pointer :: x(:)
62 type(pdt(:)), allocatable
:: x(:)
65 type(pdt(1)), pointer :: x(:)
68 type(pdt(1)), allocatable
:: x(:)
76 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
78 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
80 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
82 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
84 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
86 !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
88 !ERROR: Actual argument type 'CLASS(*)' is not compatible with dummy argument type 'CLASS(t)'
90 !ERROR: Actual argument type 'CLASS(*)' is not compatible with dummy argument type 'CLASS(t)'
92 !ERROR: POINTER or ALLOCATABLE dummy and actual arguments must have the same declared type and kind
94 !ERROR: POINTER or ALLOCATABLE dummy and actual arguments must have the same declared type and kind
96 !ERROR: Rank of dummy argument is 1, but actual argument has rank 2
98 !ERROR: Rank of dummy argument is 1, but actual argument has rank 2
106 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
108 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
110 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
112 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
114 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
116 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
124 character(len
=10), allocatable
:: t1
, t2
, t3
, t4
125 character(len
=:), allocatable
:: t5
, t6
, t7
, t8(:)
127 character(len
=10), pointer :: p1
128 character(len
=:), pointer :: p2
130 integer, allocatable
:: x(:)
135 character(len
=:), allocatable
, intent(in
) :: a
139 character(len
=10), allocatable
, intent(in
) :: a
143 character(len
=:), pointer, intent(in
) :: p
147 character(len
=10), pointer, intent(in
) :: p
151 integer, allocatable
, intent(in
) :: b(:)
156 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
161 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
166 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
169 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
172 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
177 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
182 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
185 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
188 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
191 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
194 !ERROR: ALLOCATABLE dummy argument 'a=' must be associated with an ALLOCATABLE actual argument
197 !ERROR: ALLOCATABLE dummy argument 'b=' must be associated with an ALLOCATABLE actual argument
200 !ERROR: Rank of dummy argument is 1, but actual argument has rank 0
201 !ERROR: ALLOCATABLE dummy argument 'b=' must be associated with an ALLOCATABLE actual argument
204 !ERROR: ALLOCATABLE dummy argument 'b=' must be associated with an ALLOCATABLE actual argument
220 type(t(:)), allocatable
:: p(:)
224 type(t(10)), allocatable
:: p(:)
226 !ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE