]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.fortran/array-slices-bad.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / array-slices-bad.exp
CommitLineData
1d506c26 1# Copyright 2020-2024 Free Software Foundation, Inc.
a5c641b5
AB
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
16# Test invalid element and slice array accesses.
17
57b7402d 18require allow_fortran_tests
a5c641b5
AB
19
20standard_testfile ".f90"
21load_lib fortran.exp
22
23if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
24 {debug f90}]} {
25 return -1
26}
27
2e2d1ccd
IA
28if {![runto [gdb_get_line_number "First Breakpoint"]]} {
29 perror "couldn't run to breakpoint First Breakpoint"
30 return -1
31}
32
c8ed8c8a
TV
33# Avoid shared lib symbols.
34gdb_test_no_output "set auto-solib-add off"
35
c8ed8c8a
TV
36# Avoid libc symbols, in particular the 'array' type.
37gdb_test_no_output "nosharedlibrary"
38
a5c641b5
AB
39gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
40gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
41
a5c641b5
AB
42# Access not yet allocated array.
43gdb_test "print other" " = <not allocated>"
44gdb_test "print other(0:4,2:3)" "array not allocated"
45gdb_test "print other(1,1)" "no such vector element \\(vector not allocated\\)"
46
47# Access not yet associated pointer.
48gdb_test "print pointer2d" " = <not associated>"
49gdb_test "print pointer2d(1:2,1:2)" "array not associated"
50gdb_test "print pointer2d(1,1)" "no such vector element \\(vector not associated\\)"
51
52gdb_continue_to_breakpoint "Second Breakpoint"
53
54# Accessing just outside the arrays.
55foreach name {array pointer2d other} {
56 gdb_test "print $name (0:,:)" "array subscript out of bounds"
57 gdb_test "print $name (:11,:)" "array subscript out of bounds"
58 gdb_test "print $name (:,0:)" "array subscript out of bounds"
59 gdb_test "print $name (:,:11)" "array subscript out of bounds"
60
61 gdb_test "print $name (0,:)" "no such vector element"
62 gdb_test "print $name (11,:)" "no such vector element"
63 gdb_test "print $name (:,0)" "no such vector element"
64 gdb_test "print $name (:,11)" "no such vector element"
65}
66
67# Stride in the wrong direction.
68gdb_test "print array (1:10:-1,:)" "incorrect stride and boundary combination"
69gdb_test "print array (:,1:10:-1)" "incorrect stride and boundary combination"
70gdb_test "print array (10:1:1,:)" "incorrect stride and boundary combination"
71gdb_test "print array (:,10:1:1)" "incorrect stride and boundary combination"