aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2017-01-06 03:34:25 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2017-01-06 03:34:25 +0000
commit435f3f7adf6c1ae34547c4859205f4ec7beb8a93 (patch)
treeef6481220571101b18b84ff2a010256645d29fce /gcc
parenta172ab790bb47dc296099506157019f8d4874637 (diff)
downloadgcc-435f3f7adf6c1ae34547c4859205f4ec7beb8a93.zip
gcc-435f3f7adf6c1ae34547c4859205f4ec7beb8a93.tar.gz
gcc-435f3f7adf6c1ae34547c4859205f4ec7beb8a93.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-pretty-print.c3
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 0e1b4dd..375dad1 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -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.
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 813bf1d..5d79519 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, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff)));
+ sprintf (xname, "<U%4hx>", ((unsigned short) ((uintptr_t) (t)
+ & 0xffff)));
name = xname;
}