Revert "[gdb/testsuite] Clean standard_output_file dir in gdb_init"
[binutils-gdb.git] / gdb / testsuite / gdb.fortran / array-slices-bad.exp
blob3f8e4434e2286573c202d44376c034f0f9715053
1 # Copyright 2020-2023 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 # Test invalid element and slice array accesses.
18 require allow_fortran_tests
20 standard_testfile ".f90"
21 load_lib fortran.exp
23 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
24 {debug f90}]} {
25 return -1
28 # Avoid shared lib symbols.
29 gdb_test_no_output "set auto-solib-add off"
31 if ![fortran_runto_main] {
32 return -1
35 # Avoid libc symbols, in particular the 'array' type.
36 gdb_test_no_output "nosharedlibrary"
38 # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
39 gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
40 gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
41 gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
43 gdb_continue_to_breakpoint "First Breakpoint"
45 # Access not yet allocated array.
46 gdb_test "print other" " = <not allocated>"
47 gdb_test "print other(0:4,2:3)" "array not allocated"
48 gdb_test "print other(1,1)" "no such vector element \\(vector not allocated\\)"
50 # Access not yet associated pointer.
51 gdb_test "print pointer2d" " = <not associated>"
52 gdb_test "print pointer2d(1:2,1:2)" "array not associated"
53 gdb_test "print pointer2d(1,1)" "no such vector element \\(vector not associated\\)"
55 gdb_continue_to_breakpoint "Second Breakpoint"
57 # Accessing just outside the arrays.
58 foreach name {array pointer2d other} {
59 gdb_test "print $name (0:,:)" "array subscript out of bounds"
60 gdb_test "print $name (:11,:)" "array subscript out of bounds"
61 gdb_test "print $name (:,0:)" "array subscript out of bounds"
62 gdb_test "print $name (:,:11)" "array subscript out of bounds"
64 gdb_test "print $name (0,:)" "no such vector element"
65 gdb_test "print $name (11,:)" "no such vector element"
66 gdb_test "print $name (:,0)" "no such vector element"
67 gdb_test "print $name (:,11)" "no such vector element"
70 # Stride in the wrong direction.
71 gdb_test "print array (1:10:-1,:)" "incorrect stride and boundary combination"
72 gdb_test "print array (:,1:10:-1)" "incorrect stride and boundary combination"
73 gdb_test "print array (10:1:1,:)" "incorrect stride and boundary combination"
74 gdb_test "print array (:,10:1:1)" "incorrect stride and boundary combination"