implement support for "enum class"

Message ID 1400681049.9184.9.camel@bordewijk.wildebeest.org
State Committed
Headers

Commit Message

Mark Wielaard May 21, 2014, 2:04 p.m. UTC
  Hi Tom,

On Mon, 2014-03-31 at 12:19 -0600, Tom Tromey wrote:
> Mark> I am also not sure what the right thing to do is here. But I think it
> Mark> makes sense to make printing it depend on the language used and always
> Mark> print it when the language supports "derived enums" whether the user
> Mark> explicitly defined it or it was guessed by the compiler. It is an valid
> Mark> expression in any case and the GDB user might appreciate the extra info
> Mark> (in the case of C++).
> 
> I went this route.
> 
> Here's a new patch, this one regtested on x86-64 Fedora 20 against both
> the system compiler and a GCC with your enum patches applied.  I had to
> update gdb.cp/classes.exp and I added a new test as well.

The gcc patch is almost in... (I hope). While testing it I found one
more testcase that should get the same treatment as gdb.cp/classes.exp
to optionally accept a underlying type in the case of C++.

With the gcc patch you'll get the following 9 failures otherwise:

FAIL: gdb.cp/var-tag.exp: before start: c++: ptype E
FAIL: gdb.cp/var-tag.exp: before start: c++: ptype ee
FAIL: gdb.cp/var-tag.exp: before start: c++: ptype EE
FAIL: gdb.cp/var-tag.exp: in main: c++: ptype E
FAIL: gdb.cp/var-tag.exp: in main: c++: ptype ee
FAIL: gdb.cp/var-tag.exp: in main: c++: ptype EE
FAIL: gdb.cp/var-tag.exp: in C::f: c++: ptype E
FAIL: gdb.cp/var-tag.exp: in C::f: c++: ptype ee
FAIL: gdb.cp/var-tag.exp: in C::f: c++: ptype EE

With the testsuite tweak all these PASS.

Does this look OK to check in?

Thanks,

Mark
  

Comments

Tom Tromey May 21, 2014, 2:24 p.m. UTC | #1
>>>>> "Mark" == Mark Wielaard <mjw@redhat.com> writes:

Mark> 	* gdb.cp/var-tag.exp (do_global_tests): Handle underlying type.

Thanks, Mark.
This is ok.

Tom
  

Patch

>From 0458987f529e6451a83aa10c5107ae4b9fa7fa50 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Wed, 21 May 2014 16:00:05 +0200
Subject: [PATCH] gdb/testsuite: Handle underlying type in gdb.cp/var-tag.exp.

	* gdb.cp/var-tag.exp (do_global_tests): Handle underlying type.
---
 gdb/testsuite/ChangeLog          |    4 ++++
 gdb/testsuite/gdb.cp/var-tag.exp |   12 +++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index be0bdf3..1afc9d5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@ 
+2014-05-21  Mark Wielaard  <mjw@redhat.com>
+
+	* gdb.cp/var-tag.exp (do_global_tests): Handle underlying type.
+
 2014-05-20  Pedro Alves  <palves@redhat.com>
 
 	* gdb.base/compare-sections.c: New file.
diff --git a/gdb/testsuite/gdb.cp/var-tag.exp b/gdb/testsuite/gdb.cp/var-tag.exp
index 7869fa2..9e46282 100644
--- a/gdb/testsuite/gdb.cp/var-tag.exp
+++ b/gdb/testsuite/gdb.cp/var-tag.exp
@@ -26,19 +26,25 @@  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
 }
 
 proc do_global_tests {lang} {
+    if {$lang == "c++"} {
+	set opt_underlying "(: unsigned int )?"
+    } else {
+	set opt_underlying ""
+    }
+
     if {$lang == "c"} {
 	set invalid_print "No symbol \"%s\" in current context."
 	set ptypefmt $invalid_print
     } else {
 	set invalid_print "Attempt to use a type name as an expression"
-	set ptypefmt "type = (class|enum|union|struct) %s {.*}"
+	set ptypefmt "type = (class|enum|union|struct) %s $opt_underlying{.*}"
     }
 
     with_test_prefix $lang {
 	gdb_test_no_output "set language $lang"
 	gdb_test "ptype C" "type = class C {.*}"
 	gdb_test "print E" "= a"
-	gdb_test "ptype E" "type = enum E {.*}"
+	gdb_test "ptype E" "type = enum E $opt_underlying{.*}"
 	gdb_test "print S" "= {<No data fields>}"
 	gdb_test "ptype S" "type = struct S {.*}"
 	gdb_test "print U" "= {.*}"
@@ -52,7 +58,7 @@  proc do_global_tests {lang} {
 	gdb_test "print SS" [format $invalid_print "SS"]
 	gdb_test "ptype SS" [format $ptypefmt "SS"]
 	gdb_test "print ee" "= .*"
-	gdb_test "ptype ee" "type = enum EE {.*}"
+	gdb_test "ptype ee" "type = enum EE $opt_underlying{.*}"
 	gdb_test "print EE" [format $invalid_print "EE"]
 	gdb_test "ptype EE" [format $ptypefmt "EE"]
 	gdb_test "print uu" "= {.*}"
-- 
1.7.1