aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-07-01 11:36:58 -0600
committerTom Tromey <tromey@adacore.com>2021-08-02 10:11:22 -0600
commit03adb248d621063cbbb0ce583cbd2e016ada7a6f (patch)
tree5d600cd66576f9e36bfae3573d4d593c1288d7c1 /gdb/testsuite
parent8b12db26d161d526953ab04ad92d598fd148d0bf (diff)
downloadgdb-03adb248d621063cbbb0ce583cbd2e016ada7a6f.zip
gdb-03adb248d621063cbbb0ce583cbd2e016ada7a6f.tar.gz
gdb-03adb248d621063cbbb0ce583cbd2e016ada7a6f.tar.bz2
Defer Ada character literal resolution
In Ada, an enumeration type can use a character literal as one of the enumerators. The Ada expression parser handles the appropriate conversion. It turns out, though, that this conversion was handled incorrectly. For an expression like TYPE'(EXP), the conversion would be done for any such literal appearing in EXP -- but only the outermost such expression should really be affected. This patch defers the conversion until the resolution phase, fixing the bug.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.ada/char_enum_overload.exp34
-rw-r--r--gdb/testsuite/gdb.ada/char_enum_overload/foo.adb22
-rw-r--r--gdb/testsuite/gdb.ada/char_enum_overload/pck.adb31
-rw-r--r--gdb/testsuite/gdb.ada/char_enum_overload/pck.ads25
4 files changed, 112 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/char_enum_overload.exp b/gdb/testsuite/gdb.ada/char_enum_overload.exp
new file mode 100644
index 0000000..2cd93f8
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum_overload.exp
@@ -0,0 +1,34 @@
+# Copyright 2021 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/>.
+
+load_lib "ada.exp"
+
+if { [skip_ada_tests] } { return -1 }
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+gdb_test "print pck.Global_Enum_Type'(Overloaded('+'))" "= 1 'Y'" \
+ "call correct overload"
+gdb_test "print pck.Global_Enum_Type'('+')" " = 2 '\\+'" \
+ "use enum constant"
diff --git a/gdb/testsuite/gdb.ada/char_enum_overload/foo.adb b/gdb/testsuite/gdb.ada/char_enum_overload/foo.adb
new file mode 100644
index 0000000..ee0a0aa
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum_overload/foo.adb
@@ -0,0 +1,22 @@
+-- Copyright 2021 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/>.
+
+with Pck; use Pck;
+
+procedure Foo is
+ Gchar : Global_Enum_Type := Global_Enum_Type'(Overloaded('+'));
+begin
+ Do_Nothing (Gchar'Address); -- STOP
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/char_enum_overload/pck.adb b/gdb/testsuite/gdb.ada/char_enum_overload/pck.adb
new file mode 100644
index 0000000..6aba048
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum_overload/pck.adb
@@ -0,0 +1,31 @@
+-- Copyright 2021 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/>.
+
+package body Pck is
+ procedure Overloaded (Value : Global_Enum_Type) is
+ begin
+ null;
+ end Overloaded;
+
+ function Overloaded (Value : Character) return Global_Enum_Type is
+ begin
+ return 'Y';
+ end Overloaded;
+
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/char_enum_overload/pck.ads b/gdb/testsuite/gdb.ada/char_enum_overload/pck.ads
new file mode 100644
index 0000000..7dc478f
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum_overload/pck.ads
@@ -0,0 +1,25 @@
+-- Copyright 2021 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/>.
+
+with System;
+
+package Pck is
+ type Global_Enum_Type is ('x', 'Y', '+');
+
+ procedure Overloaded (Value : Global_Enum_Type);
+ function Overloaded (Value : Character) return Global_Enum_Type;
+
+ procedure Do_Nothing (A : System.Address);
+end Pck;