Remove outermost loop parameter.
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / data_invalid.f90
blob10ea7e57c0819505c376a2e693d039946e88422c
1 ! { dg-do "compile" }
2 ! { dg-options "-std=f95 -fmax-errors=0" }
4 ! Testcases from PR fortran/24978
7 SUBROUTINE data_init_scalar_invalid()
8 integer :: a
9 data a / 1 /
10 data a / 1 / ! { dg-error "re-initialization" }
12 integer :: b = 0
13 data b / 1 / ! { dg-error "re-initialization" }
14 END SUBROUTINE
16 SUBROUTINE data_init_array_invalid()
17 ! initialize (at least) one element, re-initialize full array
18 integer :: a(3)
19 data a(2) / 2 /
20 data a / 3*1 / ! { dg-error "re-initialization" }
22 ! initialize (at least) one element, re-initialize subsection including the element
23 integer :: b(3)
24 data b(2) / 2 /
25 data b(1:2) / 2*1 / ! { dg-error "re-initialization" }
27 ! initialize subsection, re-initialize (intersecting) subsection
28 integer :: c(3)
29 data c(1:2) / 2*1 /
30 data c(2:3) / 1,1 / ! { dg-error "re-initialization" }
32 ! initialize subsection, re-initialize full array
33 integer :: d(3)
34 data d(2:3) / 2*1 /
35 data d / 2*2, 3 / ! { dg-error "re-initialization" }
37 ! full array initializer, re-initialize (at least) one element
38 integer :: e(3)
39 data e / 3*1 /
40 data e(2) / 2 / ! { dg-error "re-initialization" }
42 integer :: f(3) = 0 ! { dg-error "already is initialized" }
43 data f(2) / 1 /
45 ! full array initializer, re-initialize subsection
46 integer :: g(3)
47 data g / 3*1 /
48 data g(1:2) / 2*2 / ! { dg-error "re-initialization" }
50 integer :: h(3) = 1 ! { dg-error "already is initialized" }
51 data h(2:3) / 2*2 /
53 ! full array initializer, re-initialize full array
54 integer :: i(3)
55 data i / 3*1 /
56 data i / 2,2,2 / ! { dg-error "re-initialization" }
58 integer :: j(3) = 1 ! { dg-error "already is initialized" }
59 data j / 3*2 /
60 END SUBROUTINE
62 SUBROUTINE data_init_matrix_invalid()
63 ! initialize (at least) one element, re-initialize full matrix
64 integer :: a(3,3)
65 data a(2,2) / 1 /
66 data a / 9*2 / ! { dg-error "re-initialization" }
68 ! initialize (at least) one element, re-initialize subsection
69 integer :: b(3,3)
70 data b(2,2) / 1 /
71 data b(2,:) / 3*2 / ! { dg-error "re-initialization" }
73 ! initialize subsection, re-initialize (intersecting) subsection
74 integer :: c(3,3)
75 data c(3,:) / 3*1 /, c(:,3) / 3*2 / ! { dg-error "re-initialization" }
77 ! initialize subsection, re-initialize full array
78 integer :: d(3,3)
79 data d(2,:) / 1,2,3 /
80 data d / 9*4 / ! { dg-error "re-initialization" }
82 ! full array initializer, re-initialize (at least) one element
83 integer :: e(3,3)
84 data e / 9*1 /
85 data e(2,3) / 2 / ! { dg-error "re-initialization" }
87 integer :: f(3,3) = 1 ! { dg-error "already is initialized" }
88 data f(3,2) / 2 /
90 ! full array initializer, re-initialize subsection
91 integer :: g(3,3)
92 data g / 9 * 1 /
93 data g(2:3,2:3) / 2, 2*3, 4 / ! { dg-error "re-initialization" }
95 integer :: h(3,3) = 1 ! { dg-error "already is initialized" }
96 data h(2:3,2:3) / 2, 2*3, 4 /
98 ! full array initializer, re-initialize full array
99 integer :: i(3,3)
100 data i / 3*1, 3*2, 3*3 /
101 data i / 9 * 1 / ! { dg-error "re-initialization" }
103 integer :: j(3,3) = 0 ! { dg-error "already is initialized" }
104 data j / 9 * 1 /
105 END SUBROUTINE
107 SUBROUTINE data_init_misc_invalid()
108 ! wrong number of dimensions
109 integer :: a(3)
110 data a(1,1) / 1 / ! { dg-error "Rank mismatch" }
112 ! index out-of-bounds, direct access
113 integer :: b(3)
114 data b(-2) / 1 / ! { dg-error "below array lower bound" }
116 ! index out-of-bounds, implied do-loop (PR32315)
117 integer :: i
118 character(len=20), dimension(4) :: string
119 data (string(i), i = 1, 5) / 'A', 'B', 'C', 'D', 'E' / ! { dg-error "above array upper bound" }
120 END SUBROUTINE
122 ! { dg-excess-errors "" }