https://gcc.gnu.org/g:2fc17730dcef182bba3c9d4e32fc00302ef421fe

commit r15-7768-g2fc17730dcef182bba3c9d4e32fc00302ef421fe
Author: Jan Dubiec <j...@o2.pl>
Date:   Fri Feb 28 22:01:42 2025 -0700

    [PATCH] H8/300: PR target/109189 Silence -Wformat warnings on Windows
    
    This patch fixes annoying -Wformat warnings when gcc is built
    on Windows/MinGW64. Instead of %ld it uses HOST_WIDE_INT_PRINT_DEC
    macro, just like many other targets do.
    
            PR target/109189
    gcc/ChangeLog:
    
            * config/h8300/h8300.cc (h8300_print_operand): Replace %ld format
            strings with HOST_WIDE_INT_PRINT_DEC macro in order to silence
            -Wformat warnings when building on Windows/MinGW64.

Diff:
---
 gcc/config/h8300/h8300.cc | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
index 00135e8d02dc..02056d0ff19f 100644
--- a/gcc/config/h8300/h8300.cc
+++ b/gcc/config/h8300/h8300.cc
@@ -1444,7 +1444,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
          fprintf (file, "%sl", names_big[REGNO (x)]);
          break;
        case CONST_INT:
-         fprintf (file, "#%ld", (-INTVAL (x)) & 0xff);
+         fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (-INTVAL (x)) & 0xff);
          break;
        default:
          gcc_unreachable ();
@@ -1457,7 +1457,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
          fprintf (file, "%sh", names_big[REGNO (x)]);
          break;
        case CONST_INT:
-         fprintf (file, "#%ld", ((-INTVAL (x)) & 0xff00) >> 8);
+         fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, ((-INTVAL (x)) & 0xff00) 
>> 8);
          break;
        default:
          gcc_unreachable ();
@@ -1465,7 +1465,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 'G':
       gcc_assert (GET_CODE (x) == CONST_INT);
-      fprintf (file, "#%ld", 0xff & (-INTVAL (x)));
+      fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, 0xff & (-INTVAL (x)));
       break;
     case 'S':
       if (GET_CODE (x) == REG)
@@ -1542,7 +1542,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
          h8300_print_operand (file, x, 0);
          break;
        case CONST_INT:
-         fprintf (file, "#%ld", ((INTVAL (x) >> 16) & 0xffff));
+         fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, ((INTVAL (x) >> 16) & 
0xffff));
          break;
        case CONST_DOUBLE:
          {
@@ -1567,7 +1567,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
          h8300_print_operand (file, x, 0);
          break;
        case CONST_INT:
-         fprintf (file, "#%ld", INTVAL (x) & 0xffff);
+         fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 0xffff);
          break;
        case CONST_DOUBLE:
          {
@@ -1621,7 +1621,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 's':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", (INTVAL (x)) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x)) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 0));
       else
@@ -1629,7 +1629,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 't':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", (INTVAL (x) >> 8) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x) >> 8) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 1));
       else
@@ -1637,7 +1637,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 'w':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", INTVAL (x) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 0));
       else
@@ -1645,7 +1645,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 'x':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", (INTVAL (x) >> 8) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x) >> 8) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 1));
       else
@@ -1653,7 +1653,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 'y':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", (INTVAL (x) >> 16) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x) >> 16) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 0));
       else
@@ -1661,7 +1661,7 @@ h8300_print_operand (FILE *file, rtx x, int code)
       break;
     case 'z':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "#%ld", (INTVAL (x) >> 24) & 0xff);
+       fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x) >> 24) & 0xff);
       else if (GET_CODE (x) == REG)
        fprintf (file, "%s", byte_reg (x, 1));
       else

Reply via email to