diff mbox series

Fix a config/s390/s390.c diagnostics bug (PR target/79846)

Message ID 20190307195341.GI7611@tucnak
State New
Headers show
Series Fix a config/s390/s390.c diagnostics bug (PR target/79846) | expand

Commit Message

Jakub Jelinek March 7, 2019, 7:53 p.m. UTC
Hi!

As mentioned in the PR, using HOST_WIDE_INT_PRINT_* in the middle of
translatable message is highly undesirable, we end up with:
#: config/s390/s390.c:737
#, gcc-internal-format
msgid "constant argument %d for builtin %qF is out of range (0.."
msgstr ""

#: config/s390/s390.c:754
#, gcc-internal-format
msgid "constant argument %d for builtin %qF is out of range ("
msgstr ""
in gcc.pot that way and nothing is translated.

The following patch should fix that by using proper %wu/%wd.
Tested by building a cross-compiler to s390x-linux, ok for trunk?

2019-03-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/79846
	* config/s390/s390.c (s390_const_operand_ok): Use %wu instead of
	HOST_WIDE_INT_PRINT_UNSIGNED and %wd instead of
	HOST_WIDE_INT_PRINT_DEC.  Formatting fixes.


	Jakub

Comments

Richard Biener March 8, 2019, 10:37 a.m. UTC | #1
On Thu, Mar 7, 2019 at 8:53 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> As mentioned in the PR, using HOST_WIDE_INT_PRINT_* in the middle of
> translatable message is highly undesirable, we end up with:
> #: config/s390/s390.c:737
> #, gcc-internal-format
> msgid "constant argument %d for builtin %qF is out of range (0.."
> msgstr ""
>
> #: config/s390/s390.c:754
> #, gcc-internal-format
> msgid "constant argument %d for builtin %qF is out of range ("
> msgstr ""
> in gcc.pot that way and nothing is translated.
>
> The following patch should fix that by using proper %wu/%wd.
> Tested by building a cross-compiler to s390x-linux, ok for trunk?

OK.

Richard.

> 2019-03-07  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/79846
>         * config/s390/s390.c (s390_const_operand_ok): Use %wu instead of
>         HOST_WIDE_INT_PRINT_UNSIGNED and %wd instead of
>         HOST_WIDE_INT_PRINT_DEC.  Formatting fixes.
>
> --- gcc/config/s390/s390.c.jj   2019-02-18 20:48:32.873728534 +0100
> +++ gcc/config/s390/s390.c      2019-03-07 18:13:44.757949114 +0100
> @@ -734,10 +734,9 @@ s390_const_operand_ok (tree arg, int arg
>        if (!tree_fits_uhwi_p (arg)
>           || tree_to_uhwi (arg) > (HOST_WIDE_INT_1U << bitwidth) - 1)
>         {
> -         error("constant argument %d for builtin %qF is out of range (0.."
> -               HOST_WIDE_INT_PRINT_UNSIGNED ")",
> -               argnum, decl,
> -               (HOST_WIDE_INT_1U << bitwidth) - 1);
> +         error ("constant argument %d for builtin %qF is out of range "
> +                "(0..%wu)", argnum, decl,
> +                (HOST_WIDE_INT_1U << bitwidth) - 1);
>           return false;
>         }
>      }
> @@ -751,12 +750,10 @@ s390_const_operand_ok (tree arg, int arg
>           || tree_to_shwi (arg) < -(HOST_WIDE_INT_1 << (bitwidth - 1))
>           || tree_to_shwi (arg) > ((HOST_WIDE_INT_1 << (bitwidth - 1)) - 1))
>         {
> -         error("constant argument %d for builtin %qF is out of range ("
> -               HOST_WIDE_INT_PRINT_DEC ".."
> -               HOST_WIDE_INT_PRINT_DEC ")",
> -               argnum, decl,
> -               -(HOST_WIDE_INT_1 << (bitwidth - 1)),
> -               (HOST_WIDE_INT_1 << (bitwidth - 1)) - 1);
> +         error ("constant argument %d for builtin %qF is out of range "
> +                "(%wd..%wd)", argnum, decl,
> +                -(HOST_WIDE_INT_1 << (bitwidth - 1)),
> +                (HOST_WIDE_INT_1 << (bitwidth - 1)) - 1);
>           return false;
>         }
>      }
>
>         Jakub
diff mbox series

Patch

--- gcc/config/s390/s390.c.jj	2019-02-18 20:48:32.873728534 +0100
+++ gcc/config/s390/s390.c	2019-03-07 18:13:44.757949114 +0100
@@ -734,10 +734,9 @@  s390_const_operand_ok (tree arg, int arg
       if (!tree_fits_uhwi_p (arg)
 	  || tree_to_uhwi (arg) > (HOST_WIDE_INT_1U << bitwidth) - 1)
 	{
-	  error("constant argument %d for builtin %qF is out of range (0.."
-		HOST_WIDE_INT_PRINT_UNSIGNED ")",
-		argnum, decl,
-		(HOST_WIDE_INT_1U << bitwidth) - 1);
+	  error ("constant argument %d for builtin %qF is out of range "
+		 "(0..%wu)", argnum, decl,
+		 (HOST_WIDE_INT_1U << bitwidth) - 1);
 	  return false;
 	}
     }
@@ -751,12 +750,10 @@  s390_const_operand_ok (tree arg, int arg
 	  || tree_to_shwi (arg) < -(HOST_WIDE_INT_1 << (bitwidth - 1))
 	  || tree_to_shwi (arg) > ((HOST_WIDE_INT_1 << (bitwidth - 1)) - 1))
 	{
-	  error("constant argument %d for builtin %qF is out of range ("
-		HOST_WIDE_INT_PRINT_DEC ".."
-		HOST_WIDE_INT_PRINT_DEC ")",
-		argnum, decl,
-		-(HOST_WIDE_INT_1 << (bitwidth - 1)),
-		(HOST_WIDE_INT_1 << (bitwidth - 1)) - 1);
+	  error ("constant argument %d for builtin %qF is out of range "
+		 "(%wd..%wd)", argnum, decl,
+		 -(HOST_WIDE_INT_1 << (bitwidth - 1)),
+		 (HOST_WIDE_INT_1 << (bitwidth - 1)) - 1);
 	  return false;
 	}
     }