From patchwork Fri Mar 28 11:21:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 332 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (caibbdcaabij.dreamhost.com [208.113.200.189]) by wilcox.dreamhost.com (Postfix) with ESMTP id 633AF36065D for ; Fri, 28 Mar 2014 04:21:12 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 2169843ED75A; Fri, 28 Mar 2014 04:21:12 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id EB10243ED77D for ; Fri, 28 Mar 2014 04:21:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:cc:in-reply-to:references :content-type:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=D78mHqvU2PWE9mey 6f8IVbgI2c+C69KaHEhWwIP3Mau7CQhLmnfJYUWkzF5D31b/JZDVGte0gp0ECU/U /7bxHcDP3rz+nUv5Lk6dhBFJHq3IrlUPIEbm7zKWPCqbPX/fHx4DBv+W2KkOYL01 DAAOLmZ/LP3PM1vzwCrm1guPfAI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:cc:in-reply-to:references :content-type:date:message-id:mime-version :content-transfer-encoding; s=default; bh=DAzHSPEFjIYnL46j1BIkhu uKkTo=; b=DtAwv6fcwRFycqrt+i5hC+u/t2a1gK1sOFjhpjSnblOkwABzr14/uu 1VahsujR0kvIC68+5ea+MDGDO1umghbihC3gIezwdH7ggPJgfZdrnUA0B7LF21DW kRjqRk2pYx0syrlEwpmHiYh93fX4RcAi8q9bgWKjrKbgfOdg/LIdc= 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-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@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> Date: Fri, 28 Mar 2014 12:21:04 +0100 Message-ID: <1396005664.3824.70.camel@bordewijk.wildebeest.org> Mime-Version: 1.0 X-DH-Original-To: gdb@patchwork.siddhesh.in 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: Cheers, Mark 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));