1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 !Testing data constraints : C876, C877
9 !ERROR: Host-associated object 'first' must not be initialized in a DATA statement
21 integer, allocatable
:: a
23 character(len
=i
), pointer:: charPtr
24 character(len
=i
), allocatable
:: charAlloc
26 !ERROR: Dummy argument 'i' must not be initialized in a DATA statement
29 !ERROR: Function result 'f' must not be initialized in a DATA statement
32 !ERROR: Procedure 'g' must not be initialized in a DATA statement
35 !ERROR: Allocatable 'a' must not be initialized in a DATA statement
38 !ERROR: Automatic variable 'b' must not be initialized in a DATA statement
41 !Ok: As charPtr is a pointer, it is not an automatic object
42 DATA charPtr
/ NULL() /
44 !ERROR: Allocatable 'charalloc' must not be initialized in a DATA statement
45 DATA charAlloc
/ 'abc' /
49 subroutine CheckObject(i
)
53 type(specialNumbers
), pointer :: headOfTheList
54 integer, pointer, dimension(:) :: ptoarray
55 character, pointer, dimension(:) :: ptochar
58 integer, allocatable
:: allocVal
59 integer, allocatable
:: elt(:)
61 type(specialNumbers
) numsArray(10)
63 type(large
) largeNumber
64 type(large
), allocatable
:: allocatableLarge
65 type(large
) :: largeNumberArray(i
)
66 type(large
) :: largeArray(5)
71 type(small
), pointer :: sp
73 DATA(largeNumber
% numsArray(j
) % headOfTheList
, j
= 1, 10) / 10 * NULL() /
75 !ERROR: Data object must not contain pointer 'headofthelist' as a non-rightmost part
76 DATA(largeNumber
% numsArray(j
) % headOfTheList
% one
, j
= 1, 10) / 10 * 1 /
78 !ERROR: Rightmost data object pointer 'ptoarray' must not be subscripted
79 DATA(largeNumber
% numsArray(j
) % ptoarray(1), j
= 1, 10) / 10 * 1 /
81 !ERROR: Rightmost data object pointer 'ptochar' must not be subscripted
82 DATA largeNumber
% numsArray(1) % ptochar(1:2) / 'ab' /
84 !ERROR: Allocatable 'elt' must not be initialized in a DATA statement
85 DATA(largeNumber
% elt(j
) , j
= 1, 10) / 10 * 1/
87 !ERROR: Allocatable 'allocval' must not be initialized in a DATA statement
88 DATA(largeArray(j
) % allocVal
, j
= 1, 10) / 10 * 1/
90 !ERROR: Allocatable 'allocatablelarge' must not be initialized in a DATA statement
91 DATA allocatableLarge
% val
/ 1 /
93 !ERROR: Automatic variable 'largenumberarray' must not be initialized in a DATA statement
94 DATA(largeNumberArray(j
) % val
, j
= 1, 10) / 10 * NULL() /
96 !ERROR: Automatic variable 'name' must not be initialized in a DATA statement
97 DATA name( : 2) / 'Ancd' /
98 !ERROR: Target of pointer 'sp' must not be initialized in a DATA statement
116 type(newType
) m2_number1
119 subroutine checkDerivedType(m2_number
)
120 type(newType
) m2_number
121 type(newType
) m2_number3
123 !ERROR: Dummy argument 'm2_number' must not be initialized in a DATA statement
124 DATA m2_number
%number
/1/
126 !ERROR: Host-associated object 'm2_number1' must not be initialized in a DATA statement
127 DATA m2_number1
%number
/1/
129 !OK: m2_number3 is not associated through use association
130 DATA m2_number3
%number
/1/
136 type(newType
) m2_number2
138 !ERROR: USE-associated object 'm2_i' must not be initialized in a DATA statement
141 !ERROR: USE-associated object 'm2_number1' must not be initialized in a DATA statement
142 DATA m2_number1
%number
/1/
144 !OK: m2_number2 is not associated through use association
145 DATA m2_number2
%number
/1/