Patchwork [C++] PR 51777

login
register
mail settings
Submitter Paolo Carlini
Date Jan. 16, 2012, 5:12 p.m.
Message ID <4F145A6A.2080702@oracle.com>
Download mbox | patch
Permalink /patch/136327/
State New
Headers show

Comments

Paolo Carlini - Jan. 16, 2012, 5:12 p.m.
Hi,

in this diagnostic issue we incorrectly print unsigned template 
arguments as signed. The fix seems straightforward: just use the very 
same algorithm used in dump_generic_node for INTEGER_CST, thus dispatch 
to either pp_wide_integer or  pp_unsigned_wide_integer.

Booted and tested C++ (testing in progress for C etc.)

Ok for mainline?

Thanks,
Paolo.

///////////////////////
2012-01-16  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51777
	* c-pretty-print.c (pp_c_integer_constant): For unsigned constants
	use pp_unsigned_wide_integer.
Jason Merrill - Jan. 17, 2012, 3:38 a.m.
OK.

Jason

Patch

Index: c-pretty-print.c
===================================================================
--- c-pretty-print.c	(revision 183211)
+++ c-pretty-print.c	(working copy)
@@ -910,8 +910,10 @@  pp_c_integer_constant (c_pretty_printer *pp, tree
     ? TYPE_CANONICAL (TREE_TYPE (i))
     : TREE_TYPE (i);
 
-  if (TREE_INT_CST_HIGH (i) == 0)
+  if (host_integerp (i, 0))
     pp_wide_integer (pp, TREE_INT_CST_LOW (i));
+  else if (host_integerp (i, 1))
+    pp_unsigned_wide_integer (pp, TREE_INT_CST_LOW (i));
   else
     {
       unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (i);