brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · fe2d16e Raw
73 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12!Test for checking data constraints, C882-C8873module m14  type person5    integer :: age6    character(len=25) :: name7  end type8  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 = -112  integer :: myAge = 213  type(person) associated14  type hasAlloc15    integer, allocatable :: a16  end type17end18 19subroutine CheckRepeat20  use m121  type(person) myName(6)22  !C88223  !ERROR: Missing initialization for parameter 'uninitialized'24  integer, parameter :: uninitialized25  !C88226  !ERROR: Repeat count (-1) for data value must not be negative27  DATA myName(1)%age / repeat * 35 /28  !C88229  !ERROR: Repeat count (-11) for data value must not be negative30  DATA myName(2)%age / digits(1) * 35 /31  !C88232  !ERROR: Must be a constant value33  DATA myName(3)%age / repet * 35 /34  !C88535  !ERROR: Must have INTEGER type, but is REAL(4)36  DATA myName(4)%age / numbers(1) * 35 /37  !C88638  !ERROR: Must be a constant value39  DATA myName(5)%age / notConstDigits(1) * 35 /40  !C88741  !ERROR: Must be a constant value42  DATA myName(6)%age / digits(myAge) * 35 /43end44 45subroutine CheckValue46  use m147  !ERROR: USE-associated object 'associated' must not be initialized in a DATA statement48  data associated / person(1, 'Abcd Ijkl') /49  type(person) myName(3)50  !OK: constant structure constructor51  data myname(1) / person(1, 'Abcd Ijkl') /52  !C88353  !ERROR: 'persn' must be an array or structure constructor if used with non-empty parentheses as a DATA statement constant54  data myname(2) / persn(2, 'Abcd Efgh') /55  !C88456  !ERROR: DATA statement value 'person(age=myage,name="Abcd Ijkl                ")' for 'myname(3_8)%age' is not a constant57  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/)60  integer :: i61  integer :: x, y, z62  !OK: constant array element63  data x / a(1) /64  !C886, C88765  !ERROR: DATA statement value 'a(int(i,kind=8))' for 'y' is not a constant66  data y / a(i) /67  !ERROR: DATA statement value 'b(1_8)' for 'z' is not a constant68  data z / b(1) /69  type(hasAlloc) ha70  !ERROR: DATA statement value 'hasalloc(a=0_4)' for 'ha%a' is not a constant71  data ha / hasAlloc(0) /72end73