diff mbox series

Fix -Werror=format-diag with RTL checking

Message ID 008e6070-d2a0-a177-88a9-056df008d4e5@suse.cz
State New
Headers show
Series Fix -Werror=format-diag with RTL checking | expand

Commit Message

Martin Liška Jan. 20, 2022, 9:44 a.m. UTC
The patch disables -Wformat-diag for RTL checking diagnostics.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR bootstrap/104135

gcc/ChangeLog:

	* emit-rtl.cc (make_insn_raw): Fix -Wformat-diag warnings.
	* rtl.cc: Partially disable -Wformat-diag for RTL checking
	error messages.
---
  gcc/emit-rtl.cc |  2 +-
  gcc/rtl.cc      | 10 ++++++++++
  2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Jakub Jelinek Jan. 20, 2022, 10:19 a.m. UTC | #1
On Thu, Jan 20, 2022 at 10:44:18AM +0100, Martin Liška wrote:
> The patch disables -Wformat-diag for RTL checking diagnostics.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> 	PR bootstrap/104135
> 
> gcc/ChangeLog:
> 
> 	* emit-rtl.cc (make_insn_raw): Fix -Wformat-diag warnings.
> 	* rtl.cc: Partially disable -Wformat-diag for RTL checking
> 	error messages.

> --- a/gcc/emit-rtl.cc
> +++ b/gcc/emit-rtl.cc
> @@ -3997,7 +3997,7 @@ make_insn_raw (rtx pattern)
>  	  || (GET_CODE (insn) == SET
>  	      && SET_DEST (insn) == pc_rtx)))
>      {
> -      warning (0, "ICE: emit_insn used where emit_jump_insn needed:\n");
> +      warning (0, "ICE: %<emit_insn%> used where %<emit_jump_insn%> needed:");
>        debug_rtx (insn);
>      }
>  #endif
> diff --git a/gcc/rtl.cc b/gcc/rtl.cc
> index 02dd2554728..f3d85814014 100644
> --- a/gcc/rtl.cc
> +++ b/gcc/rtl.cc
> @@ -870,6 +870,12 @@ dump_rtx_statistics (void)
>  }
>  
>  #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
> +
> +#if __GNUC__ >= 10
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wformat-diag"
> +#endif

Please add a comment why we do this above #if __GNUC__ >= 10
line.

> +
>  void
>  rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
>  			 const char *func)
> @@ -945,6 +951,10 @@ rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, machine_mode mode,
>  		  func, trim_filename (file), line);
>  }
> +#if __GNUC__ >= 10
> +#pragma GCC diagnostic pop
> +#endif
> +

Please add empty line above this.
LGTM with those changes.

	Jakub
diff mbox series

Patch

diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index 3260ca8c3fa..a26bcb0fa2d 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -3997,7 +3997,7 @@  make_insn_raw (rtx pattern)
  	  || (GET_CODE (insn) == SET
  	      && SET_DEST (insn) == pc_rtx)))
      {
-      warning (0, "ICE: emit_insn used where emit_jump_insn needed:\n");
+      warning (0, "ICE: %<emit_insn%> used where %<emit_jump_insn%> needed:");
        debug_rtx (insn);
      }
  #endif
diff --git a/gcc/rtl.cc b/gcc/rtl.cc
index 02dd2554728..f3d85814014 100644
--- a/gcc/rtl.cc
+++ b/gcc/rtl.cc
@@ -870,6 +870,12 @@  dump_rtx_statistics (void)
  }
  
  #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
+
+#if __GNUC__ >= 10
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-diag"
+#endif
+
  void
  rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
  			 const char *func)
@@ -945,6 +951,10 @@  rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, machine_mode mode,
  		  func, trim_filename (file), line);
  }
  
+#if __GNUC__ >= 10
+#pragma GCC diagnostic pop
+#endif
+
  /* Report that line LINE of FILE tried to access the block symbol fields
     of a non-block symbol.  FUNC is the function that contains the line.  */