diff options
author | Tom Tromey <tromey@adacore.com> | 2022-09-26 08:24:14 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-09-28 10:45:58 -0600 |
commit | 98847c1e38b717ceb7d186fe377be53171a9225f (patch) | |
tree | 3c95431404a12b25bc8f81f3eb44d1bf50129ca7 /gdb/testsuite | |
parent | be5f79aa3952accc5133875f523875c0fa397761 (diff) | |
download | binutils-98847c1e38b717ceb7d186fe377be53171a9225f.zip binutils-98847c1e38b717ceb7d186fe377be53171a9225f.tar.gz binutils-98847c1e38b717ceb7d186fe377be53171a9225f.tar.bz2 |
Treat Character as a discrete type in Ada
A user noticed that gdb would assert when printing a certain array
with array-indexes enabled. This turned out to be caused by the array
having an index type of Character, which is completely valid in Ada.
This patch changes the Ada support to recognize Character as a
discrete type, and adds some tests.
Because this is Ada-specific and was also reviewed internally, I am
checking it in.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.ada/discrete-char.exp | 42 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/discrete-char/main.adb | 23 |
2 files changed, 65 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/discrete-char.exp b/gdb/testsuite/gdb.ada/discrete-char.exp new file mode 100644 index 0000000..762b3de --- /dev/null +++ b/gdb/testsuite/gdb.ada/discrete-char.exp @@ -0,0 +1,42 @@ +# Copyright 2022 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Tests that require character to be a discrete type. + +load_lib "ada.exp" + +if { [skip_ada_tests] } { return -1 } + +standard_ada_testfile main + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/main.adb] +if {![runto "main.adb:$bp_location"]} then { + perror "Couldn't run ${testfile}" + return +} + +gdb_test_no_output "set print array-indexes on" +gdb_test "print array_value" \ + [string_to_regexp "= (65 'A' => true, 66 'B' => false <repeats 24 times>, 90 'Z' => true)"] + +gdb_test "print character'val(65)" " = 65 'A'" +gdb_test "print character'pos('A')" " = 65" +gdb_test "print character'first" [string_to_regexp " = 0 '\[\"00\"\]'"] diff --git a/gdb/testsuite/gdb.ada/discrete-char/main.adb b/gdb/testsuite/gdb.ada/discrete-char/main.adb new file mode 100644 index 0000000..4758c3c --- /dev/null +++ b/gdb/testsuite/gdb.ada/discrete-char/main.adb @@ -0,0 +1,23 @@ +-- Copyright 2022 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +procedure Main is + type Letters is new Character range 'A' .. 'Z'; + type Array_Type is array (Letters) of Boolean; + + Array_Value : Array_Type := ('A' => true, 'Z' => true, others => false); +begin + null; -- STOP +end Main; |