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