public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Make large enum constants unsigned
@ 2014-05-22  5:30 Stefan Kristiansson
  2014-05-22  6:22 ` Maciej W. Rozycki
  2014-05-22 15:11 ` Frank Ch. Eigler
  0 siblings, 2 replies; 14+ messages in thread
From: Stefan Kristiansson @ 2014-05-22  5:30 UTC (permalink / raw)
  To: cgen
  Cc: Alan Modra, fche, Christian Svensson, Pierre Muller, Maciej W. Rozycki

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?)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-05-29 20:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22  5:30 [PATCH] Make large enum constants unsigned Stefan Kristiansson
2014-05-22  6:22 ` Maciej W. Rozycki
2014-05-22  6:52   ` Stefan Kristiansson
2014-05-22  7:10     ` Stefan Kristiansson
2014-05-22 13:33       ` Pierre Muller
     [not found]       ` <5561926758764771034@unknownmsgid>
2014-05-22 14:10         ` Stefan Kristiansson
2014-05-22 16:14       ` Maciej W. Rozycki
2014-05-22 15:11 ` Frank Ch. Eigler
2014-05-22 17:34   ` Stefan Kristiansson
2014-05-22 21:06     ` Frank Ch. Eigler
2014-05-22 21:42       ` Maciej W. Rozycki
2014-05-22 22:20         ` Frank Ch. Eigler
2014-05-29 20:09       ` Stefan Kristiansson
2014-05-29 20:32         ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).