summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/unchecked_union
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-12-03 13:31:21 -0700
committerTom Tromey <tromey@adacore.com>2019-12-10 08:56:39 -0700
commit6c71eb7d70c3678f595cd8e66d78c9da5bd3ef4e (patch)
tree771eb800267f5ffe7370e3b30962495fe68848d6 /gdb/testsuite/gdb.ada/unchecked_union
parent0a0a05217640d96938b4cd58c9ce01ef5026e15a (diff)
downloadbinutils-gdb-6c71eb7d70c3678f595cd8e66d78c9da5bd3ef4e.tar.gz
Normalize Ada ptype to use a single "?"
Sometimes -- notably with unchecked unions -- the Ada "ptype" code will print a "?" or "??" to indicate something unknown. The choice of what was printed was somewhat arbitrary, and in one case, Ada would print an empty string rather than "?". This patch normalizes the Ada code to use "?" rather than an empty string or "??". My reasoning here is that a single question mark is enough to convey unknown-ness. gdb/ChangeLog 2019-12-10 Tom Tromey <tromey@adacore.com> * ada-typeprint.c (print_choices): Use a single "?". (print_variant_part): Print "?" if the discriminant name is not known. gdb/testsuite/ChangeLog 2019-12-10 Tom Tromey <tromey@adacore.com> * gdb.ada/unchecked_union.exp: New file. * gdb.ada/unchecked_union/pck.adb: New file. * gdb.ada/unchecked_union/pck.ads: New file. * gdb.ada/unchecked_union/unchecked_union.adb: New file. * gdb-utils.exp (string_to_regexp): Also quote "?". Change-Id: I3403040780a155ffa2c44c8e6a04ba86bc810e29
Diffstat (limited to 'gdb/testsuite/gdb.ada/unchecked_union')
-rw-r--r--gdb/testsuite/gdb.ada/unchecked_union/pck.adb21
-rw-r--r--gdb/testsuite/gdb.ada/unchecked_union/pck.ads19
-rw-r--r--gdb/testsuite/gdb.ada/unchecked_union/unchecked_union.adb51
3 files changed, 91 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/unchecked_union/pck.adb b/gdb/testsuite/gdb.ada/unchecked_union/pck.adb
new file mode 100644
index 00000000000..6535991a193
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/unchecked_union/pck.adb
@@ -0,0 +1,21 @@
+-- Copyright 2019 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 Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/unchecked_union/pck.ads b/gdb/testsuite/gdb.ada/unchecked_union/pck.ads
new file mode 100644
index 00000000000..b8d00101753
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/unchecked_union/pck.ads
@@ -0,0 +1,19 @@
+-- Copyright 2019 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
+ procedure Do_Nothing (A : System.Address);
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/unchecked_union/unchecked_union.adb b/gdb/testsuite/gdb.ada/unchecked_union/unchecked_union.adb
new file mode 100644
index 00000000000..d6de66d86d9
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/unchecked_union/unchecked_union.adb
@@ -0,0 +1,51 @@
+-- Copyright 2019 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;
+with Pck; use Pck;
+
+procedure Foo is
+ type Key is (Alpha, Omega);
+
+ type Inner(Disc : Key := Omega) is record
+ case Disc is
+ when Alpha =>
+ Small : Integer range 0..255;
+ when others =>
+ Large : Integer range 255..510;
+ end case;
+ end record;
+ pragma Unchecked_Union (Inner);
+
+ type Outer(Disc : Key := Alpha) is record
+ case Disc is
+ when Alpha =>
+ Field_One : Integer range 0..255;
+ when others =>
+ Field_Two : Integer range 255..510;
+ end case;
+ end record;
+ pragma Unchecked_Union (Outer);
+
+ type Pair is record
+ Pone : Inner;
+ Ptwo : Outer;
+ end record;
+
+ Value : Pair;
+
+begin
+ Do_Nothing (Value'Address); -- BREAK
+end Foo;