H8/300: PR target/109189 Silence -Wformat warnings on Windows

Message ID b6ef269c-6585-447d-bf23-8fcdd59abd24@o2.pl
State Committed
Commit 2fc17730dcef182bba3c9d4e32fc00302ef421fe
Headers
Series H8/300: PR target/109189 Silence -Wformat warnings on Windows |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Build failed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap success Build passed

Commit Message

Jan Dubiec Feb. 27, 2025, 9:42 p.m. UTC
  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.

2025-02-27  Jan Dubiec  <jdx@o2.pl>

	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.
gcc/config/h8300/h8300.cc | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
  

Comments

Jeff Law March 1, 2025, 5:04 a.m. UTC | #1
On 2/27/25 2:42 PM, Jan Dubiec wrote:
> 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.
> 
> 2025-02-27  Jan Dubiec <jdx@o2.pl>
> 
>      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.
Thanks.  I think all this code is original stuff from Steve (so circa 
1994).  Thanks for cleaning it up!

I've pushed this to the trunk.  While we are in stage4, this is clearly 
isolated to the H8 and should be NFC.

Jeff
  

Patch

diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
index 00135e8d02d..02056d0ff19 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