From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5328 invoked by alias); 28 Mar 2014 11:21:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5315 invoked by uid 89); 28 Mar 2014 11:21:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Mar 2014 11:21:07 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2SBL61i027154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Mar 2014 07:21:06 -0400 Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2SBL5st024542; Fri, 28 Mar 2014 07:21:05 -0400 Subject: Re: [PATCH] implement support for "enum class" From: Mark Wielaard To: Tom Tromey Cc: gdb-patches@sourceware.org In-Reply-To: <1395951111-8189-1-git-send-email-tromey@redhat.com> References: <1395951111-8189-1-git-send-email-tromey@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Fri, 28 Mar 2014 11:21:00 -0000 Message-ID: <1396005664.3824.70.camel@bordewijk.wildebeest.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-03/txt/msg00652.txt.bz2 On Thu, 2014-03-27 at 14:11 -0600, Tom Tromey wrote: > This adds support for the C++11 "enum class" feature. This is > PR c++/15246. > > I chose to use the existing TYPE_DECLARED_CLASS rather than introduce > a new type code. This seemed both simple and clear to me. > > I made overloading support for the new enum types strict. This is how > it works in C++; and it didn't seem like an undue burden to keep this, > particularly because enum constants are printed symbolically by gdb. > > Built and regtested on x86-64 Fedora 20. > [...] > +gdb_test "ptype E1" \ > + "type = enum class E1 {E1::HI = 7, E1::THERE}" This FAILs for me with gcc plus http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01448.html because it will derive: Breakpoint 1, main () at /home/mark/src/binutils-gdb/gdb/testsuite/gdb.cp/enumclass.cc:45 45 return 0; (gdb) ptype E1 type = enum class E1 : int {E1::HI = 7, E1::THERE} Note the : int. I think this comes from: diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c > index 4edc9ec..04b6d7b 100644 > --- a/gdb/c-typeprint.c > +++ b/gdb/c-typeprint.c > [...] > @@ -1349,6 +1351,14 @@ c_type_print_base (struct type *type, struct ui_file *stream, > { > LONGEST lastval = 0; > > + if (TYPE_TARGET_TYPE (type) != NULL) > + { > + struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type)); > + > + if (TYPE_NAME (underlying) != NULL) > + fprintf_filtered (stream, ": %s ", TYPE_NAME (underlying)); > + } > + > fprintf_filtered (stream, "{"); > len = TYPE_NFIELDS (type); > for (i = 0; i < len; i++) If the test is right then I think you don't want to print the underlying type if DW_AT_enum_class is set and the enum has type safe semantics? Maybe: diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 04b6d7b..299d859 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1351,7 +1351,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, { LONGEST lastval = 0; - if (TYPE_TARGET_TYPE (type) != NULL) + if (TYPE_TARGET_TYPE (type) != NULL && ! TYPE_DECLARED_CLASS (type)) { struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type)); Cheers, Mark