1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 !Test for checking data constraints, C882-C887
7 character(len
=25) :: name
9 integer, parameter::digits(5) = ( /-11,-22,-33,44,55/ )
10 integer ::notConstDigits(5)
11 real, parameter::numbers(5) = ( /-11.11,-22.22,-33.33,44.44,55.55/ )
12 integer, parameter :: repeat
= -1
14 type(person
) associated
17 subroutine CheckRepeat
19 type(person
) myName(6)
21 !ERROR: Missing initialization for parameter 'uninitialized'
22 integer, parameter :: uninitialized
24 !ERROR: Repeat count (-1) for data value must not be negative
25 DATA myName(1)%age
/ repeat
* 35 /
27 !ERROR: Repeat count (-11) for data value must not be negative
28 DATA myName(2)%age
/ digits(1) * 35 /
30 !ERROR: Must be a constant value
31 DATA myName(3)%age
/ repet
* 35 /
33 !ERROR: Must have INTEGER type, but is REAL(4)
34 DATA myName(4)%age
/ numbers(1) * 35 /
36 !ERROR: Must be a constant value
37 DATA myName(5)%age
/ notConstDigits(1) * 35 /
39 !ERROR: Must be a constant value
40 DATA myName(6)%age
/ digits(myAge
) * 35 /
45 !ERROR: USE-associated object 'associated' must not be initialized in a DATA statement
46 data associated
/ person(1, 'Abcd Ijkl') /
47 type(person
) myName(3)
48 !OK: constant structure constructor
49 data myname(1) / person(1, 'Abcd Ijkl') /
51 !ERROR: 'persn' is not an array
52 data myname(2) / persn(2, 'Abcd Efgh') /
54 !ERROR: DATA statement value 'person(age=myage,name="Abcd Ijkl ")' for 'myname(3_8)%age' is not a constant
55 data myname(3) / person(myAge
, 'Abcd Ijkl') /
56 integer, parameter :: a(5) =(/11, 22, 33, 44, 55/)
57 integer :: b(5) =(/11, 22, 33, 44, 55/)
60 !OK: constant array element
63 !ERROR: DATA statement value 'a(int(i,kind=8))' for 'y' is not a constant
65 !ERROR: DATA statement value 'b(1_8)' for 'z' is not a constant