This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
RE: [PATCH] Make large enum constants unsigned
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Stefan Kristiansson'" <stefan dot kristiansson at saunalahti dot fi>, "'Maciej W. Rozycki'" <macro at codesourcery dot com>
- 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>
- Date: Thu, 22 May 2014 15:33:37 +0200
- Subject: RE: [PATCH] Make large enum constants unsigned
- Authentication-results: sourceware.org; auth=none
- References: <20140522052921 dot GA30609 at chokladfabriken dot org> <alpine dot DEB dot 1 dot 10 dot 1405220702380 dot 512 at tp dot orcam dot me dot uk> <CADzBsGObK_dNY81Lcv8HgPAP800xv2H8vf80M96-NfMo-CXcPA at mail dot gmail dot com> <20140522071001 dot GA30918 at chokladfabriken dot org>
Couldn't we support 64-bit constants already,
by adding
+ (if (> (cadr e)
+ #x100000000)
+ "LL" ""))
Right after the conditional "U" postfix?
This way, the pre C-99 standard would only be violated when
it is really required anyhow, no?
Pierre Muller
> -----Message d'origine-----
> De : Stefan Kristiansson [mailto:stefan.kristiansson@saunalahti.fi]
> Envoyé : jeudi 22 mai 2014 09:10
> À : Maciej W. Rozycki
> Cc : cgen@sourceware.org; Alan Modra; fche@sourceware.org; Christian
> Svensson; Pierre Muller
> Objet : Re: [PATCH] Make large enum constants unsigned
>
> On Thu, May 22, 2014 at 09:52:50AM +0300, Stefan Kristiansson wrote:
> >
> > As for 'u' vs 'U', a 'U' is emitted in the .h file even if I put a
> 'u'
> > in the .scm.
> > If 'u' in the output is preferred, maybe someone can point out the
> > reason for this?
> >
>
> I found the reason, there's a 'string-upcase' a couple of rows above
> what the patch touches.
> I'm not sure getting around that is worth pursuing though?
>
> Anyway, below is the updated patch.
>
> 2014-05-22 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
>
> * enum.scm (gen-enum-decl): Emit 'U' after constants larger than
> #x80000000
>
> Index: cgen/enum.scm
> ===================================================================
> RCS file: /cvs/src/src/cgen/enum.scm,v
> retrieving revision 1.13
> diff -u -r1.13 enum.scm
> --- cgen/enum.scm 13 Feb 2010 03:39:15 -0000 1.13
> +++ cgen/enum.scm 22 May 2014 07:09:00 -0000
> @@ -298,7 +298,10 @@
> ""
> (string-append " = "
> (if (number? (cadr e))
> - (number->string (cadr e))
> + (string-append (number->string (cadr
e))
> + (if (> (cadr e)
> + #x80000000)
> + "U" ""))
> (cadr e))))
> ))
> (if (and san? include-sanitize-marker?)