1 ! Copyright 2021 Free Software Foundation, Inc.
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.
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.
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/>.
16 #define DO_TEST(ARRAY) \
17 call do_test (lbound (ARRAY), ubound (ARRAY))
19 subroutine do_test (lb, ub)
20 integer, dimension (:) :: lb
21 integer, dimension (:) :: ub
24 print *, "Expected GDB Output:"
27 write(*, fmt="(A)", advance="no") "LBOUND = ("
28 do i=LBOUND (lb, 1), UBOUND (lb, 1), 1
29 if (i > LBOUND (lb, 1)) then
30 write(*, fmt="(A)", advance="no") ", "
32 write(*, fmt="(I0)", advance="no") lb (i)
34 write(*, fmt="(A)", advance="yes") ")"
36 write(*, fmt="(A)", advance="no") "UBOUND = ("
37 do i=LBOUND (ub, 1), UBOUND (ub, 1), 1
38 if (i > LBOUND (ub, 1)) then
39 write(*, fmt="(A)", advance="no") ", "
41 write(*, fmt="(I0)", advance="no") ub (i)
43 write(*, fmt="(A)", advance="yes") ")"
45 print *, "" ! Test Breakpoint
46 end subroutine do_test
49 ! Start of test program.
53 subroutine do_test (lb, ub)
54 integer, dimension (:) :: lb
55 integer, dimension (:) :: ub
56 end subroutine do_test
59 ! Declare variables used in this test.
60 integer, dimension (-8:-1,-10:-2) :: neg_array
61 integer, dimension (2:10,1:9), target :: array
62 integer, allocatable :: other (:, :)
63 character (len=26) :: str_1 = "abcdefghijklmnopqrstuvwxyz"
64 integer, dimension (-2:2,-3:3,-1:5) :: array3d
65 integer, dimension (-3:3,7:10,-4:2,-10:-7) :: array4d
66 integer, dimension (10:20) :: array1d
67 integer, dimension(:,:), pointer :: pointer2d => null()
68 integer, dimension(-2:6,-1:9), target :: tarray
71 integer, dimension (:), pointer :: pointer1d => null()
73 ! Allocate or associate any variables as needed.
74 allocate (other (-5:4, -2:7))
76 pointer1d => array (3, 2:5)
79 DO_TEST (neg_array (-7:-3,-5:-4))
81 ! The following is disabled due to a bug in gfortran:
82 ! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99027
83 ! gfortran generates the incorrect expected results.
84 ! DO_TEST (array (3, 2:5))
93 ! All done. Deallocate.
96 ! GDB catches this final breakpoint to indicate the end of the test.
97 print *, "" ! Final Breakpoint.
99 ! Reference otherwise unused locals in order to keep them around.
100 ! GDB will make use of these for some tests.