[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
This commit is contained in:
parent
a172ab790b
commit
435f3f7adf
|
@ -1,3 +1,9 @@
|
|||
2017-01-06 Alexandre Oliva <aoliva@redhat.com>
|
||||
|
||||
* 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 <ebotcazou@adacore.com>
|
||||
|
||||
* c.opt (fsso-struct): Add 'native' value.
|
||||
|
|
|
@ -2376,7 +2376,8 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
|
|||
else
|
||||
{
|
||||
static char xname[8];
|
||||
sprintf (xname, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff)));
|
||||
sprintf (xname, "<U%4hx>", ((unsigned short) ((uintptr_t) (t)
|
||||
& 0xffff)));
|
||||
name = xname;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue