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