This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
Re: [PATCH] Make large enum constants unsigned
- From: "Frank Ch. Eigler" <fche at elastic dot org>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>, cgen at sourceware dot org, Alan Modra <amodra at gmail dot com>, fche at sourceware dot org, Christian Svensson <blue at cmd dot nu>, Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>
- Date: Thu, 22 May 2014 18:20:12 -0400
- Subject: Re: [PATCH] Make large enum constants unsigned
- Authentication-results: sourceware.org; auth=none
- References: <20140522052921 dot GA30609 at chokladfabriken dot org> <20140522150956 dot GC4031 at elastic dot org> <CADzBsGN3U6a3BS5L7o7DYh_4KTghEXnB2UE0XKdNZrAN=A0p=g at mail dot gmail dot com> <20140522210621 dot GF4031 at elastic dot org> <alpine dot DEB dot 1 dot 10 dot 1405222229270 dot 512 at tp dot orcam dot me dot uk>
Hi -
> > > > (string-append "(signed int)" (number->string (cadr e)))
> > > [...]
> > > how would that be better than?
> > > (string-append (number->string (cadr e)) "U")
> >
> > It would be a closer match to expressing our desire to match C enum
> > typing, but I'd be fine with "U" suffixing too.
>
> TBH I don't understand what you mean here, a C compiler is free to choose
> from `char', `int' and `unsigned int' as the underlying (compatible) type
> of an enumeration as long as the type can represent all the member values
> defined. [...]
I'm not a language lawyer, and in different levels of the language
this has changed, but my understanding is that to be most compatible,
the enumerators (the given literals) need to be 'int's. (It's a
separate question as to what type the compiler would allocate to an
enum FOO variable.)
> over the `unsigned int' type here? If this is used to produce a bit mask,
> which I gather it is, then I find using an unsigned type more natural.
I see what you mean.
- FChE