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

commit r13-8760-g2a6f99aef7c8522471967b171180d9ba4136da90
Author: David Malcolm <dmalc...@redhat.com>
Date:   Thu May 9 13:09:32 2024 -0400

    Fix ICE in -fdiagnostics-generate-patch [PR112684]
    
    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 <dmalc...@redhat.com>

Diff:
---
 gcc/toplev.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 109c9d58cbd1..19391208eac2 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);

Reply via email to