[20/21] Fix ICE in -fdiagnostics-generate-patch [PR112684]

Message ID 20240509174236.2278921-21-dmalcolm@redhat.com
State New
Headers
Series Various backports to gcc 13 (analyzer, jit, diagnostics) |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

David Malcolm May 9, 2024, 5:42 p.m. UTC
  Backported from r14-8255-ge254d1224df306.

gcc/ChangeLog:
	PR middle-end/112684
	* toplev.cc (toplev::main): Don't ICE in
	-fdiagnostics-generate-patch when exiting after options,
	since no edit context will have been created.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/toplev.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Patch

diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 109c9d58cbd..19391208eac 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -2292,10 +2292,8 @@  toplev::main (int argc, char **argv)
      emit some diagnostics here.  */
   invoke_plugin_callbacks (PLUGIN_FINISH, NULL);
 
-  if (flag_diagnostics_generate_patch)
+  if (global_dc->edit_context_ptr)
     {
-      gcc_assert (global_dc->edit_context_ptr);
-
       pretty_printer pp;
       pp_show_color (&pp) = pp_show_color (global_dc->printer);
       global_dc->edit_context_ptr->print_diff (&pp, true);