xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/array-slices-repeat.f90 (revision 3117ece4fc4a4ca4489ba793710b60b0d26bab6c)
1! Copyright 2022-2023 Free Software Foundation, Inc.
2!
3! This program is free software; you can redistribute it and/or modify
4! it under the terms of the GNU General Public License as published by
5! the Free Software Foundation; either version 3 of the License, or
6! (at your option) any later version.
7!
8! This program is distributed in the hope that it will be useful,
9! but WITHOUT ANY WARRANTY; without even the implied warranty of
10! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11! GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License
14! along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16subroutine show (array_1d, array_1d9, array_2d, array_2d9, array_3d, array_3d9)
17  integer, dimension (-2:) :: array_1d
18  integer, dimension (-2:) :: array_1d9
19  integer, dimension (-2:, -2:) :: array_2d
20  integer, dimension (-2:, -2:) :: array_2d9
21  integer, dimension (-2:, -2:, -2:) :: array_3d
22  integer, dimension (-2:, -2:, -2:) :: array_3d9
23
24  print *, ""           ! Break here
25  print *, array_1d
26  print *, array_1d9
27  print *, array_2d
28  print *, array_2d9
29  print *, array_3d
30  print *, array_3d9
31end subroutine show
32
33!
34! Start of test program.
35!
36program test
37  interface
38    subroutine show (array_1d, array_1d9, array_2d, array_2d9, &
39		     array_3d, array_3d9)
40      integer, dimension (:) :: array_1d
41      integer, dimension (:) :: array_1d9
42      integer, dimension (:, :) :: array_2d
43      integer, dimension (:, :) :: array_2d9
44      integer, dimension (:, :, :) :: array_3d
45      integer, dimension (:, :, :) :: array_3d9
46    end subroutine show
47  end interface
48
49  ! Declare variables used in this test.
50  integer, dimension (-8:6) :: array_1d
51  integer, dimension (-8:9) :: array_1d9
52  integer, dimension (-8:6, -8:6) :: array_2d
53  integer, dimension (-8:9, -8:9) :: array_2d9
54  integer, dimension (-8:6, -8:6, -8:6) :: array_3d
55  integer, dimension (-8:9, -8:9, -8:9) :: array_3d9
56
57  integer, parameter :: v6 (6) = [-5, -4, -3, 1, 2, 3]
58  integer, parameter :: v9 (9) = [-5, -4, -3, 1, 2, 3, 7, 8, 9]
59
60  ! Intersperse slices selected with varying data to make sure it is
61  ! correctly ignored for the purpose of repeated element recognition
62  ! in the slices.
63  array_1d = 7
64  array_1d (::3) = 1
65  array_1d9 = 7
66  array_1d9 (::3) = 1
67  array_1d9 (7) = 9
68  array_2d = 7
69  array_2d (:, v6) = 6
70  array_2d (::3, ::3) = 2
71  array_2d9 = 7
72  array_2d9 (:, v9) = 6
73  array_2d9 (::3, ::3) = 2
74  array_2d9 (7, ::3) = 9
75  array_2d9 (::3, 7) = 9
76  array_3d = 7
77  array_3d (:, v6, :) = 6
78  array_3d (:, v6, v6) = 5
79  array_3d (::3, ::3, ::3) = 3
80  array_3d9 = 7
81  array_3d9 (:, v9, :) = 6
82  array_3d9 (:, v9, v9) = 5
83  array_3d9 (::3, ::3, ::3) = 3
84  array_3d9 (7, ::3, ::3) = 9
85  array_3d9 (::3, 7, ::3) = 9
86  array_3d9 (::3, ::3, 7) = 9
87
88  call show (array_1d (::3), array_1d9 (::3), &
89	     array_2d (::3, ::3), array_2d9 (::3, ::3), &
90	     array_3d (::3, ::3, ::3), array_3d9 (::3, ::3, ::3))
91
92  print *, array_1d
93  print *, array_1d9
94  print *, array_2d
95  print *, array_2d9
96  print *, array_3d
97  print *, array_3d9
98
99end program test
100