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: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>
- Cc: 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>, "Maciej W. Rozycki" <macro at codesourcery dot com>
- Date: Thu, 29 May 2014 16:30:58 -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> <20140529200819 dot GA9229 at chokladfabriken dot org>
Hi -
> [...]
> Ok, that's fine by me if others are ok with it.
> Below is the patch that does that.
>
> 2014-05-29 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
>
> * enum.scm (gen-enum-decl): Emit 'U' after constants.
> [...]
One last piece of homework: can you identify in your patch the range
of c compilers / standards-compliance-CFLAGS tested with this change?
I'm a bit worried that U-suffixing may be rejected by earlier or
non-gnu compilers.
A little experiment shows, gcc 4.8 with -ansi -pedantic outright
rejects large integers, with or without U suffix.
gcc -ansi -pedantic -c foo.c
foo.c:1:14: warning: ISO C restricts enumerator values to range of âintâ [-Wpedantic]
enum i { x = 4000000000U };
It accepts with a (int)4000000000 casting formulation instead.
- FChE