1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 !Test for checking data constraints, C882-C887
6 character(len
=25) :: name
8 integer, parameter::digits(5) = ( /-11,-22,-33,44,55/ )
9 integer ::notConstDigits(5)
10 real, parameter::numbers(5) = ( /-11.11,-22.22,-33.33,44.44,55.55/ )
11 integer, parameter :: repeat
= -1
13 type(person
) associated
15 integer, allocatable
:: a
19 subroutine CheckRepeat
21 type(person
) myName(6)
23 !ERROR: Missing initialization for parameter 'uninitialized'
24 integer, parameter :: uninitialized
26 !ERROR: Repeat count (-1) for data value must not be negative
27 DATA myName(1)%age
/ repeat
* 35 /
29 !ERROR: Repeat count (-11) for data value must not be negative
30 DATA myName(2)%age
/ digits(1) * 35 /
32 !ERROR: Must be a constant value
33 DATA myName(3)%age
/ repet
* 35 /
35 !ERROR: Must have INTEGER type, but is REAL(4)
36 DATA myName(4)%age
/ numbers(1) * 35 /
38 !ERROR: Must be a constant value
39 DATA myName(5)%age
/ notConstDigits(1) * 35 /
41 !ERROR: Must be a constant value
42 DATA myName(6)%age
/ digits(myAge
) * 35 /
47 !ERROR: USE-associated object 'associated' must not be initialized in a DATA statement
48 data associated
/ person(1, 'Abcd Ijkl') /
49 type(person
) myName(3)
50 !OK: constant structure constructor
51 data myname(1) / person(1, 'Abcd Ijkl') /
53 !ERROR: 'persn' must be an array or structure constructor if used with non-empty parentheses as a DATA statement constant
54 data myname(2) / persn(2, 'Abcd Efgh') /
56 !ERROR: DATA statement value 'person(age=myage,name="Abcd Ijkl ")' for 'myname(3_8)%age' is not a constant
57 data myname(3) / person(myAge
, 'Abcd Ijkl') /
58 integer, parameter :: a(5) =(/11, 22, 33, 44, 55/)
59 integer :: b(5) =(/11, 22, 33, 44, 55/)
62 !OK: constant array element
65 !ERROR: DATA statement value 'a(int(i,kind=8))' for 'y' is not a constant
67 !ERROR: DATA statement value 'b(1_8)' for 'z' is not a constant
70 !ERROR: DATA statement value 'hasalloc(a=0_4)' for 'ha' is not a constant
71 data ha
/ hasAlloc(0) /