Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Mark Wielaard <mjw@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] implement support for "enum class"
Date: Mon, 31 Mar 2014 04:38:00 -0000	[thread overview]
Message-ID: <87y4zrhtj0.fsf@fleche.redhat.com> (raw)
In-Reply-To: <1396005664.3824.70.camel@bordewijk.wildebeest.org> (Mark	Wielaard's message of "Fri, 28 Mar 2014 12:21:04 +0100")

>>>>> "Mark" == Mark Wielaard <mjw@redhat.com> 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


  reply	other threads:[~2014-03-31  4:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 20:12 Tom Tromey
2014-03-28 11:21 ` Mark Wielaard
2014-03-31  4:38   ` Tom Tromey [this message]
2014-03-31  7:16     ` Mark Wielaard
2014-03-31 18:19       ` Tom Tromey
2014-04-14 18:07         ` Tom Tromey
2014-05-21 14:04         ` Mark Wielaard
2014-05-21 14:25           ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y4zrhtj0.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mjw@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox