aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-07-01 18:26:50 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-07-01 18:26:50 +0000
commit8f17729f21e54827ba8de614be382c4fbd6b690f (patch)
tree92add7a0018deb53f1793f0ea2d22f4fc38fd14d /gdb/testsuite/gdb.ada
parentf5aa6869dee6874a9d1a3a386b1d5893f0ac46d4 (diff)
downloadgdb-8f17729f21e54827ba8de614be382c4fbd6b690f.zip
gdb-8f17729f21e54827ba8de614be382c4fbd6b690f.tar.gz
gdb-8f17729f21e54827ba8de614be382c4fbd6b690f.tar.bz2
treat identical enum types as the same type
This is to avoid an unnecessary multiple-choice menu for an expression involving an enumeral declared in two types, when the second type is an identical copy of the first type. This happens in the following situation: type Color is (Black, Red, Green, Blue, White); type RGB_Color is new Color range Red .. Blue; In that case, an implict type is created, and is used as the base type for type RGB_Color. This base type is a copy of type Color. We've added some extensive comments explaining the situation and our approach further. gdb/ChangeLog: * ada-lang.c (ada_identical_enum_types_p): New function. (symbols_are_identical_enums): New function. (remove_extra_symbols): Do nothing if NSYMS < 2. Use symbols_are_identical_enums. gdb/testsuite/ChangeLog: * gdb.ada/same_enum: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/same_enum.exp37
-rw-r--r--gdb/testsuite/gdb.ada/same_enum/a.adb24
-rw-r--r--gdb/testsuite/gdb.ada/same_enum/pck.adb22
-rw-r--r--gdb/testsuite/gdb.ada/same_enum/pck.ads24
4 files changed, 107 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/same_enum.exp b/gdb/testsuite/gdb.ada/same_enum.exp
new file mode 100644
index 0000000..3f8b372
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/same_enum.exp
@@ -0,0 +1,37 @@
+# Copyright 2011 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"
+
+set testdir "same_enum"
+set testfile "${testdir}/a"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+# Try printing the value of the enumeral `red'. This is normally
+# ambiguous, as there are two distinct types that define that
+# littleral. But, from a practical standpoint, it doesn't matter
+# which one we pick, since both have the same value (in most cases,
+# it's because the two types are strongly related).
+gdb_test "print red" "= red"
+
+
diff --git a/gdb/testsuite/gdb.ada/same_enum/a.adb b/gdb/testsuite/gdb.ada/same_enum/a.adb
new file mode 100644
index 0000000..094fe76
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/same_enum/a.adb
@@ -0,0 +1,24 @@
+-- Copyright 2011 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 A is
+ FC : Color := Red;
+ SC : Color := Green;
+begin
+ Do_Nothing (FC'Address);
+ Do_Nothing (SC'Address);
+end A;
diff --git a/gdb/testsuite/gdb.ada/same_enum/pck.adb b/gdb/testsuite/gdb.ada/same_enum/pck.adb
new file mode 100644
index 0000000..01fdc3d
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/same_enum/pck.adb
@@ -0,0 +1,22 @@
+-- Copyright 2011 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/same_enum/pck.ads b/gdb/testsuite/gdb.ada/same_enum/pck.ads
new file mode 100644
index 0000000..01da514
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/same_enum/pck.ads
@@ -0,0 +1,24 @@
+-- Copyright 2011 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 Color is (Black, Red, Green, Blue, White);
+ type RGB_Color is new Color range Red .. Blue;
+
+ procedure Do_Nothing (A : System.Address);
+end Pck;
+