This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
[PATCH] Make large enum constants unsigned
- From: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>
- To: cgen at sourceware dot org
- Cc: 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, 22 May 2014 08:29:22 +0300
- Subject: [PATCH] Make large enum constants unsigned
- Authentication-results: sourceware.org; auth=none
Hi,
this fixes a bug noted in two threads on the binutils mailing list:
https://sourceware.org/ml/binutils/2014-05/msg00152.html
https://sourceware.org/ml/binutils/2014-05/msg00195.html
Both threads describe the problem pretty well, but the gist of it
is that constants are generated that will be interpreted as signed.
2014-05-22 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
* enum.scm (gen-enum-decl): Emit 'ULL' 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 05:23:23 -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)
+ "ULL" ""))
(cadr e))))
))
(if (and san? include-sanitize-marker?)