1! RUN: %python %S/test_errors.py %s %flang_fc1 2!Test for checking data constraints, C882-C887 3module m1 4 type person 5 integer :: age 6 character(len=25) :: name 7 end type 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 12 integer :: myAge = 2 13 type(person) associated 14end 15 16subroutine CheckRepeat 17 use m1 18 type(person) myName(6) 19 !C882 20 !ERROR: Missing initialization for parameter 'uninitialized' 21 integer, parameter :: uninitialized 22 !C882 23 !ERROR: Repeat count (-1) for data value must not be negative 24 DATA myName(1)%age / repeat * 35 / 25 !C882 26 !ERROR: Repeat count (-11) for data value must not be negative 27 DATA myName(2)%age / digits(1) * 35 / 28 !C882 29 !ERROR: Must be a constant value 30 DATA myName(3)%age / repet * 35 / 31 !C885 32 !ERROR: Must have INTEGER type, but is REAL(4) 33 DATA myName(4)%age / numbers(1) * 35 / 34 !C886 35 !ERROR: Must be a constant value 36 DATA myName(5)%age / notConstDigits(1) * 35 / 37 !C887 38 !ERROR: Must be a constant value 39 DATA myName(6)%age / digits(myAge) * 35 / 40end 41 42subroutine CheckValue 43 use m1 44 !ERROR: USE-associated object 'associated' must not be initialized in a DATA statement 45 data associated / person(1, 'Abcd Ijkl') / 46 type(person) myName(3) 47 !OK: constant structure constructor 48 data myname(1) / person(1, 'Abcd Ijkl') / 49 !C883 50 !ERROR: 'persn' must be an array or structure constructor if used with non-empty parentheses as a DATA statement constant 51 data myname(2) / persn(2, 'Abcd Efgh') / 52 !C884 53 !ERROR: DATA statement value 'person(age=myage,name="Abcd Ijkl ")' for 'myname(3_8)%age' is not a constant 54 data myname(3) / person(myAge, 'Abcd Ijkl') / 55 integer, parameter :: a(5) =(/11, 22, 33, 44, 55/) 56 integer :: b(5) =(/11, 22, 33, 44, 55/) 57 integer :: i 58 integer :: x, y, z 59 !OK: constant array element 60 data x / a(1) / 61 !C886, C887 62 !ERROR: DATA statement value 'a(int(i,kind=8))' for 'y' is not a constant 63 data y / a(i) / 64 !ERROR: DATA statement value 'b(1_8)' for 'z' is not a constant 65 data z / b(1) / 66end 67