diff mbox

Patch correcting possible bug in toplevel.c regarding plugin & diagnostics finalizartion

Message ID 1380648509.4738.13.camel@glinka.lesours
State New
Headers show

Commit Message

Basile Starynkevitch Oct. 1, 2013, 5:28 p.m. UTC
Hello All

I'm re-reading toplev_main from gcc/toplev.c and I find strange that
invoke_plugin_callbacks for PLUGIN_FINISH was called before
diagnostic_finish (which I guess is finalizing all the diagnostic
infrastructure).

My guess would be that some GCC plugins might occasionally emit a
diagnostic at PLUGIN_FINISH stage. Imagine a plugin which fills some
database (e.g. with software metrics). It would probably close the
database at PLUGIN_FINISH, and in the rare event that database closing
fails, emit a diagnostic (using e.g. error)


######## proposed patch against trunk svn rev 203073

######## proposed gcc/ChangeLog entry

2013-10-01  Basile Starynkevitch  <basile@starynkevitch.net>

	* toplev.c (toplev_main): Move PLUGIN_FINISH invocation before 
          diagnostic_finish.

#####

I am not entirely sure about this patch (because I don't fully
understand what diagnostic_finish is supposed to do, just partly
guessing it). Comments are welcome.

Regards
diff mbox

Patch

Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 203073)
+++ gcc/toplev.c	(working copy)
@@ -1970,11 +1970,13 @@  toplev_main (int argc, char **argv)
 
   if (warningcount || errorcount || werrorcount)
     print_ignored_options ();
-  diagnostic_finish (global_dc);
 
-  /* Invoke registered plugin callbacks if any.  */
+  /* Invoke registered plugin callbacks if any.  Some plugins could
+     emit some diagnostics here.  */
   invoke_plugin_callbacks (PLUGIN_FINISH, NULL);
 
+  diagnostic_finish (global_dc);
+
   finalize_plugins ();
   location_adhoc_data_fini (line_table);
   if (seen_error () || werrorcount)