[NFC][RISCV] Remove CFIIndex argument from allocateStack (#117871)
[llvm-project.git] / flang / test / Semantics / data03.f90
blobd9bead778433b339891d94dfe9c8bb4deb47c529
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 !Testing data constraints : C874 - C875, C878 - C881
3 module m
4 integer, target :: modarray(1)
5 contains
6 function f(i)
7 integer, intent(in) :: i
8 integer, pointer :: f
9 f => modarray(i)
10 end
11 subroutine CheckObject
12 type specialNumbers
13 integer one
14 integer numbers(5)
15 end type
16 type large
17 integer elt(10)
18 integer val
19 type(specialNumbers) nums
20 type(specialNumbers) numsArray(5)
21 end type
22 type(specialNumbers), parameter ::newNums = &
23 specialNumbers(1, (/ 1, 2, 3, 4, 5 /))
24 type(specialNumbers), parameter ::newNumsArray(2) = &
25 (/ SpecialNumbers(1, (/ 1, 2, 3, 4, 5 /)), &
26 SpecialNumbers(1, (/ 1, 2, 3,4, 5 /)) /)
27 type(specialNumbers) nums
28 type(large) largeArray(5)
29 type(large) largeNumber
30 real :: a[*]
31 real :: b(5)
32 integer :: x
33 real, parameter:: c(5) = (/ 1, 2, 3, 4, 5 /)
34 integer :: d(10, 10)
35 character :: name(12)
36 integer :: ind = 2
37 !ERROR: Data statement object must be a variable
38 DATA name%len / 666 /
39 !C874
40 !ERROR: Data object must not be a coindexed variable
41 DATA a[1] / 1 /
42 !C874
43 !ERROR: Data object must not be a coindexed variable
44 DATA(a[i], i = 1, 5) / 5 * 1 /
45 !C875
46 !ERROR: Data object variable must not be a function reference
47 DATA f(1) / 1 /
48 !C875
49 !ERROR: Data object must have constant subscripts
50 DATA b(ind) / 1 /
51 !C875
52 !ERROR: Data object must have constant subscripts
53 DATA name( : ind) / 'Ancd' /
54 !C875
55 !ERROR: Data object must have constant subscripts
56 DATA name(ind:) / 'Ancd' /
57 !C878
58 !ERROR: Data implied do object must be a variable
59 DATA(c(i), i = 1, 5) / 5 * 1 /
60 !C878
61 !ERROR: Data implied do object must be a variable
62 DATA(newNumsArray(i), i = 1, 2) &
63 / specialNumbers(1, 2 * (/ 1, 2, 3, 4, 5 /)) /
64 !C880
65 !ERROR: Data implied do structure component must be subscripted
66 DATA(nums % one, i = 1, 5) / 5 * 1 /
67 !C879
68 !ERROR: Data implied do object must be a variable
69 DATA(newNums % numbers(i), i = 1, 5) / 5 * 1 /
70 !C879
71 !ERROR: Data implied do object must be a variable
72 DATA(newNumsArray(i) % one, i = 1, 5) / 5 * 1 /
73 !C880
74 !OK: Correct use
75 DATA(largeArray(j) % nums % one, j = 1, 5) / 5 * 1 /
76 !C880
77 !OK: Correct use
78 DATA(largeNumber % numsArray(j) % one, j = 1, 5) / 5 * 1 /
79 !C881
80 !ERROR: Data object must have constant subscripts
81 DATA(b(x), i = 1, 5) / 5 * 1 /
82 !C881
83 !OK: Correct use
84 DATA(nums % numbers(i), i = 1, 5) / 5 * 1 /
85 !C881
86 !OK: Correct use
87 DATA((d(i, j), i = 1, 10), j = 1, 10) / 100 * 1 /
88 !C881
89 !OK: Correct use
90 DATA(d(i, 1), i = 1, 10) / 10 * 1 /
91 end
92 end