1! RUN: %B/test/Semantics/test_errors.sh %s %flang %t 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) = ( /-11,-22,-33,44,55/ ) 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) myName 14end 15 16subroutine CheckRepeat 17 use m1 18 !C882 19 !ERROR: Missing initialization for parameter 'uninitialized' 20 integer, parameter :: uninitialized 21 !C882 22 !ERROR: Repeat count for data value must not be negative 23 DATA myName%age / repeat * 35 / 24 !C882 25 !ERROR: Repeat count for data value must not be negative 26 DATA myName%age / digits(1) * 35 / 27 !C882 28 !ERROR: Must be a constant value 29 DATA myName%age / repet * 35 / 30 !C885 31 !ERROR: Must have INTEGER type, but is REAL(4) 32 DATA myName%age / numbers(1) * 35 / 33 !C886 34 !ERROR: Must be a constant value 35 DATA myName%age / notConstDigits(1) * 35 / 36 !C887 37 !ERROR: Must be a constant value 38 DATA myName%age / digits(myAge) * 35 / 39end 40 41subroutine CheckValue 42 use m1 43 !OK: constant structure constructor 44 data myname / person(1, 'Abcd Ijkl') / 45 !C883 46 !ERROR: 'persn' is not an array 47 data myname / persn(2, 'Abcd Efgh') / 48 !C884 49 !ERROR: Structure constructor in data value must be a constant expression 50 data myname / person(myAge, 'Abcd Ijkl') / 51 integer, parameter :: a(5) =(/11, 22, 33, 44, 55/) 52 integer :: b(5) =(/11, 22, 33, 44, 55/) 53 integer :: i 54 integer :: x 55 !OK: constant array element 56 data x / a(1) / 57 !C886, C887 58 !ERROR: Must be a constant value 59 data x / a(i) / 60 !ERROR: Must be a constant value 61 data x / b(1) / 62end 63