pp_c_character_constant only calls pp_p_char for values that fit into
a HWI of the constant's signedness (i.e. an unsigned HWI if TYPE_UNSIGNED
and a signed HWI otherwise).  But pp_c_character_constant is only called by:

    case INTEGER_CST:
      {
        tree type = TREE_TYPE (e);
        ...
        else if (type == char_type_node)
          pp_c_character_constant (this, e);

and in practice a character constant is always going to fit into a HWI.
The current !host_integerp case simply truncates the constant to an
unsigned int anyway.

Maybe the type == wchar_type_node test is dead too, I'm not sure.
I'm happy to remove it at the same time if that seems like the right
thing to do.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/c-family/
        * c-pretty-print.c (pp_c_character_constant): Remove unnecessary
        host_integerp check.

Index: gcc/c-family/c-pretty-print.c
===================================================================
--- gcc/c-family/c-pretty-print.c       2013-11-14 20:21:27.183058648 +0000
+++ gcc/c-family/c-pretty-print.c       2013-11-14 20:22:20.664818284 +0000
@@ -954,10 +954,7 @@ pp_c_character_constant (c_pretty_printe
   if (type == wchar_type_node)
     pp_character (pp, 'L');
   pp_quote (pp);
-  if (host_integerp (c, TYPE_UNSIGNED (type)))
-    pp_c_char (pp, tree_low_cst (c, TYPE_UNSIGNED (type)));
-  else
-    pp_scalar (pp, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
+  pp_c_char (pp, (unsigned) TREE_INT_CST_LOW (c));
   pp_quote (pp);
 }
 

Reply via email to