From: Alexandre Oliva Date: Fri, 6 Jan 2017 03:34:25 +0000 (+0000) Subject: [bootstrap-O1] change value type to avoid sprintf buffer size warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=435f3f7adf6c1ae34547c4859205f4ec7beb8a93;p=gcc.git [bootstrap-O1] change value type to avoid sprintf buffer size warning In stage2 of bootstrap-O1, the code that warns if sprintf might overflow its output buffer cannot tell that an unsigned value narrowed to 16 bits will fit in 4 bytes with %4x. Converting the value to 'unsigned short' makes it obvious that it fits, at least on machines with 16-bit shorts. for gcc/c-family/ChangeLog * c-pretty-print.c (pp_c_tree_decl_identifier): Convert 16-bit value to unsigned short to fit in 4 hex digits without warnings. From-SVN: r244121 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0e1b4dda006..375dad19358 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-01-06 Alexandre Oliva + + * c-pretty-print.c (pp_c_tree_decl_identifier): Convert 16-bit + value to unsigned short to fit in 4 hex digits without + warnings. + 2017-01-05 Eric Botcazou * c.opt (fsso-struct): Add 'native' value. diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 813bf1da8af..5d79519fa7d 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -2376,7 +2376,8 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t) else { static char xname[8]; - sprintf (xname, "", ((unsigned)((uintptr_t)(t) & 0xffff))); + sprintf (xname, "", ((unsigned short) ((uintptr_t) (t) + & 0xffff))); name = xname; }