aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-05-03 12:18:26 -0600
committerTom Tromey <tromey@adacore.com>2019-05-03 17:04:56 -0600
commit222a8d255834c717f1690658a9f85501a46f9403 (patch)
tree181737fca35a8953bc59e915c910d0d18eaf489f /gdb/testsuite
parentfcd60b848ed7619461b0b0e316201e7745cdb61d (diff)
downloadgdb-222a8d255834c717f1690658a9f85501a46f9403.zip
gdb-222a8d255834c717f1690658a9f85501a46f9403.tar.gz
gdb-222a8d255834c717f1690658a9f85501a46f9403.tar.bz2
Fix cast of character to enum type in Ada
An internal bug report points out that, when a global character enum type is used, casting fails, like: (gdb) print global_char_enum'('F') $1 = 70 The bug here turns out to be that enumerators are qualified, so for example the mangled name might be "pck__QU48", rather than "QU48". This patch fixes the problem by only examining the suffix of the enumerator. This is ok because the type is already known, and because the mangling scheme ensures that there won't be clashes. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-03 Tom Tromey <tromey@adacore.com> * ada-exp.y (convert_char_literal): Check suffix of each enumerator. gdb/testsuite/ChangeLog 2019-05-03 Tom Tromey <tromey@adacore.com> * gdb.ada/char_enum/pck.ads (Global_Enum_Type): New type. * gdb.ada/char_enum/foo.adb: Use Global_Enum_Type. * gdb.ada/char_enum.exp: Add test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.ada/char_enum.exp3
-rw-r--r--gdb/testsuite/gdb.ada/char_enum/foo.adb1
-rw-r--r--gdb/testsuite/gdb.ada/char_enum/pck.ads1
4 files changed, 9 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c5bdddb..72fc0d8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-03 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/char_enum/pck.ads (Global_Enum_Type): New type.
+ * gdb.ada/char_enum/foo.adb: Use Global_Enum_Type.
+ * gdb.ada/char_enum.exp: Add test.
+
2019-05-03 Tom de Vries <tdevries@suse.de>
* boards/cc-with-gdb-index.exp: New file.
diff --git a/gdb/testsuite/gdb.ada/char_enum.exp b/gdb/testsuite/gdb.ada/char_enum.exp
index 4b35fcb..c37d696 100644
--- a/gdb/testsuite/gdb.ada/char_enum.exp
+++ b/gdb/testsuite/gdb.ada/char_enum.exp
@@ -27,5 +27,4 @@ set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
runto "foo.adb:$bp_location"
gdb_test "print Char_Enum_Type'('B')" "= 1 'B'"
-
-
+gdb_test "print pck.Global_Enum_Type'('Y')" "= 1 'Y'"
diff --git a/gdb/testsuite/gdb.ada/char_enum/foo.adb b/gdb/testsuite/gdb.ada/char_enum/foo.adb
index 95914da..cf7fb7d 100644
--- a/gdb/testsuite/gdb.ada/char_enum/foo.adb
+++ b/gdb/testsuite/gdb.ada/char_enum/foo.adb
@@ -18,6 +18,7 @@ with Pck; use Pck;
procedure Foo is
type Char_Enum_Type is ('A', 'B', 'C', 'D', 'E');
Char : Char_Enum_Type := 'D';
+ Gchar : Global_Enum_Type := 'Z';
begin
Do_Nothing (Char'Address); -- STOP
end Foo;
diff --git a/gdb/testsuite/gdb.ada/char_enum/pck.ads b/gdb/testsuite/gdb.ada/char_enum/pck.ads
index 5dd0388..f952e1c 100644
--- a/gdb/testsuite/gdb.ada/char_enum/pck.ads
+++ b/gdb/testsuite/gdb.ada/char_enum/pck.ads
@@ -16,6 +16,7 @@
with System;
package Pck is
+ type Global_Enum_Type is ('X', 'Y', 'Z');
procedure Do_Nothing (A : System.Address);
end Pck;