RISC-V: don't cast expressions' X_add_number to long in diagnostics

Message ID e76ef8f7-72b9-5103-cb43-9608af01d017@suse.com
State Accepted, archived
Headers
Series RISC-V: don't cast expressions' X_add_number to long in diagnostics |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Jan Beulich Sept. 30, 2022, 9:42 a.m. UTC
  There's no need for such workarounds anymore now that we use C99
uniformly. This addresses several testsuite failures encountered when
(cross-)building on a 32-bit host.
  

Comments

Christoph Müllner Sept. 30, 2022, 10:13 a.m. UTC | #1
Hi Jan,

Thanks for pointing that out!
I admit, that I was just following the established pattern in this file.
There are four more identical cases in this file ("improper "... outputs).
I'll take care of them (unless you pick them up as well).

Tested-by: Christoph Müllner <christoph.muellner@vrull.eu>

Thanks,
Christoph

On Fri, Sep 30, 2022 at 11:42 AM Jan Beulich <jbeulich@suse.com> wrote:

> There's no need for such workarounds anymore now that we use C99
> uniformly. This addresses several testsuite failures encountered when
> (cross-)building on a 32-bit host.
>
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -3338,14 +3338,14 @@ riscv_ip (char *str, struct riscv_cl_ins
>                       if (!sign)
>                         {
>                           if (!VALIDATE_U_IMM (imm_expr->X_add_number, n))
> -                           as_bad (_("improper immediate value (%lu)"),
> -                                   (unsigned long)
> imm_expr->X_add_number);
> +                           as_bad (_("improper immediate value
> (%"PRIu64")"),
> +                                   imm_expr->X_add_number);
>                         }
>                       else
>                         {
>                           if (!VALIDATE_S_IMM (imm_expr->X_add_number, n))
> -                           as_bad (_("improper immediate value (%li)"),
> -                                   (long) imm_expr->X_add_number);
> +                           as_bad (_("improper immediate value
> (%"PRIi64")"),
> +                                   imm_expr->X_add_number);
>                         }
>                       INSERT_IMM (n, s, *ip, imm_expr->X_add_number);
>                       imm_expr->X_op = O_absent;
>
  
Nelson Chu Sept. 30, 2022, 2:43 p.m. UTC | #2
Thanks, please commit.

Nelson

On Fri, Sep 30, 2022 at 5:42 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> There's no need for such workarounds anymore now that we use C99
> uniformly. This addresses several testsuite failures encountered when
> (cross-)building on a 32-bit host.
>
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -3338,14 +3338,14 @@ riscv_ip (char *str, struct riscv_cl_ins
>                       if (!sign)
>                         {
>                           if (!VALIDATE_U_IMM (imm_expr->X_add_number, n))
> -                           as_bad (_("improper immediate value (%lu)"),
> -                                   (unsigned long) imm_expr->X_add_number);
> +                           as_bad (_("improper immediate value (%"PRIu64")"),
> +                                   imm_expr->X_add_number);
>                         }
>                       else
>                         {
>                           if (!VALIDATE_S_IMM (imm_expr->X_add_number, n))
> -                           as_bad (_("improper immediate value (%li)"),
> -                                   (long) imm_expr->X_add_number);
> +                           as_bad (_("improper immediate value (%"PRIi64")"),
> +                                   imm_expr->X_add_number);
>                         }
>                       INSERT_IMM (n, s, *ip, imm_expr->X_add_number);
>                       imm_expr->X_op = O_absent;
  

Patch

--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -3338,14 +3338,14 @@  riscv_ip (char *str, struct riscv_cl_ins
 		      if (!sign)
 			{
 			  if (!VALIDATE_U_IMM (imm_expr->X_add_number, n))
-			    as_bad (_("improper immediate value (%lu)"),
-				    (unsigned long) imm_expr->X_add_number);
+			    as_bad (_("improper immediate value (%"PRIu64")"),
+				    imm_expr->X_add_number);
 			}
 		      else
 			{
 			  if (!VALIDATE_S_IMM (imm_expr->X_add_number, n))
-			    as_bad (_("improper immediate value (%li)"),
-				    (long) imm_expr->X_add_number);
+			    as_bad (_("improper immediate value (%"PRIi64")"),
+				    imm_expr->X_add_number);
 			}
 		      INSERT_IMM (n, s, *ip, imm_expr->X_add_number);
 		      imm_expr->X_op = O_absent;