[pushed] Fix ICE in -fdiagnostics-generate-patch [PR112684]

Message ID 20240118171536.1216488-1-dmalcolm@redhat.com
State Committed
Commit e254d1224df306a07f3b0b572af2582f509b7d67
Headers
Series [pushed] Fix ICE in -fdiagnostics-generate-patch [PR112684] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 warning Patch is already merged

Commit Message

David Malcolm Jan. 18, 2024, 5:15 p.m. UTC
  Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as 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 | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Patch

diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 55636ff6e80..175d4cd18fa 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -2323,11 +2323,8 @@  toplev::main (int argc, char **argv)
      emit some diagnostics here.  */
   invoke_plugin_callbacks (PLUGIN_FINISH, NULL);
 
-  if (flag_diagnostics_generate_patch)
+  if (auto edit_context_ptr = global_dc->get_edit_context ())
     {
-      auto edit_context_ptr = global_dc->get_edit_context ();
-      gcc_assert (edit_context_ptr);
-
       pretty_printer pp;
       pp_show_color (&pp) = pp_show_color (global_dc->printer);
       edit_context_ptr->print_diff (&pp, true);