On 15/01/15 21:56, Joseph Myers wrote:
On Thu, 15 Jan 2015, Jiong Wang wrote:

+  if (bitsize + bitnum > unit && bitnum < unit)
+    {
+      warning (OPT_Wextra, "write of "HOST_WIDE_INT_PRINT_UNSIGNED"bit data "
+              "outside the bound of destination object, data truncated into "
+              HOST_WIDE_INT_PRINT_UNSIGNED"bit", bitsize, unit - bitnum);
HOST_WIDE_INT_PRINT_UNSIGNED is a format for printf, not for the GCC
diagnostic functions; in addition, the strings passed to the GCC
diagnostic functions must be string constants, not concatenated with
macros (only with other string constants directly appearing in the
source), so that they can be extracted for translation.  You need to use
%wu instead to print an unsigned HOST_WIDE_INT in a GCC diagnostic
function such as warning.

(Also, there should be a hyphen between the number and "bit", "%wu-bit".)

make sense, thanks, patch installed.

Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c        (revision 219717)
+++ gcc/expmed.c        (working copy)
@@ -566,9 +566,9 @@
      etc.  */
   if (bitsize + bitnum > unit && bitnum < unit)
     {
-      warning (OPT_Wextra, "write of "HOST_WIDE_INT_PRINT_UNSIGNED"bit data "
-              "outside the bound of destination object, data truncated into "
-              HOST_WIDE_INT_PRINT_UNSIGNED"bit", bitsize, unit - bitnum);
+      warning (OPT_Wextra, "write of %wu-bit data outside the bound of "
+              "destination object, data truncated into %wu-bit",
+              bitsize, unit - bitnum);
       bitsize = unit - bitnum;
     }
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog       (revision 219717)
+++ gcc/ChangeLog       (working copy)
@@ -1,5 +1,10 @@
 2015-01-15  Jiong Wang  <jiong.w...@arm.com>
+ * expmed.c (store_bit_field_using_insv): Improve warning message.
+       Use %wu instead of HOST_WIDE_INT_PRINT_UNSIGNED.
+
+2015-01-15  Jiong Wang  <jiong.w...@arm.com>
+
        PR rtl-optimization/64011
        * expmed.c (store_bit_field_using_insv): Warn and truncate bitsize when
        there is partial overflow.



Reply via email to