From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14019 invoked by alias); 31 Mar 2014 04:38:32 -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 13998 invoked by uid 89); 31 Mar 2014 04:38:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.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; Mon, 31 Mar 2014 04:38:30 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2V4cSfF029042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 31 Mar 2014 00:38:28 -0400 Received: from barimba (ovpn-113-41.phx2.redhat.com [10.3.113.41]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2V4cRrh003076 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 31 Mar 2014 00:38:28 -0400 From: Tom Tromey To: Mark Wielaard Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] implement support for "enum class" References: <1395951111-8189-1-git-send-email-tromey@redhat.com> <1396005664.3824.70.camel@bordewijk.wildebeest.org> Date: Mon, 31 Mar 2014 04:38:00 -0000 In-Reply-To: <1396005664.3824.70.camel@bordewijk.wildebeest.org> (Mark Wielaard's message of "Fri, 28 Mar 2014 12:21:04 +0100") Message-ID: <87y4zrhtj0.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-03/txt/msg00687.txt.bz2 >>>>> "Mark" == Mark Wielaard writes: >> +gdb_test "ptype E1" \ >> + "type = enum class E1 {E1::HI = 7, E1::THERE}" Mark> This FAILs for me with gcc plus Mark> http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01448.html Thanks Mark. Mark> (gdb) ptype E1 Mark> type = enum class E1 : int {E1::HI = 7, E1::THERE} Mark> Note the : int. [...] Mark> If the test is right then I think you don't want to print the underlying Mark> type if DW_AT_enum_class is set and the enum has type safe semantics? I'm not totally sure what to do. It seems that without extra information there is no perfect answer. At least this code should (most likely) only print the ": type" part for C++, not for C. That was an oversight in the original patch. This may omit some information from the C case, but on the other hand at least the output won't be gratuitously non-C. I was anticipating that GCC would emit an unnamed type for the underlying type in the case where the underlying type is not specified in the source. However I can see why it would not necessarily do this, and certainly there's no requirement in DWARF along these lines. One option might be to have the DWARF reader omit the underlying type when the type it guessed from the enum values agreed with the type specified in DW_AT_type. Of course that's just a heuristic. It's perhaps better, I think, to just always emit the bits even if they are in some sense redundant. In C++11, whether an underlying type is specified is orthogonal to whether the enum is an "enum class". "enum x : short" is perfectly ok. Tom