Skip to content

Commit 2f10569

Browse files
committed
Add Ada test case with long array indices
This patch adds a test case to test that the previous two patches did their job. With the current gdb, this test fails: (gdb) print some_regular_access.all Value out of range. The bug here is that the array has an index type that is wider than 'int', which is perfectly acceptable in Ada. Note that this series doesn't quite go far enough: in Ada the index could be a 128-bit integer. This change would be more invasive; and in practice this doesn't really seem to come up much -- so I've deferred it.
1 parent 6c82831 commit 2f10569

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2025 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+
16+
# Test that long array index types work.
17+
18+
load_lib "ada.exp"
19+
20+
require allow_ada_tests
21+
22+
standard_ada_testfile main
23+
24+
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
25+
return
26+
}
27+
28+
clean_restart ${testfile}
29+
30+
set bp_location [gdb_get_line_number STOP ${testdir}/main.adb]
31+
if {![runto "main.adb:$bp_location"]} {
32+
return
33+
}
34+
35+
gdb_test "print some_regular_access.all" \
36+
[string_to_regexp " = (-2147483648 => (-9223372036854775808 => 1, 2, 3), (-9223372036854775808 => 4, 5, 6))"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Copyright 2025 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+
16+
with Pck; use Pck;
17+
18+
procedure Main is
19+
20+
type My_Array is array (Integer range <>, Long_Integer range <>) of Integer;
21+
22+
type My_Reg_Acc is access all My_Array;
23+
24+
Some_Regular_Access : My_Reg_Acc := new My_Array'((1, 2, 3), (4, 5, 6));
25+
26+
begin
27+
Do_Nothing (Some_Regular_Access'Address); -- STOP
28+
end Main;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Copyright 2012-2025 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+
16+
package body Pck is
17+
procedure Do_Nothing (A : System.Address) is
18+
begin
19+
null;
20+
end Do_Nothing;
21+
end Pck;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- Copyright 2012-2025 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+
16+
with System;
17+
package Pck is
18+
procedure Do_Nothing (A : System.Address);
19+
end Pck;

0 commit comments

Comments
 (0)