* diagnostic.c: Don't include plugin.h.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 13:01:45 +0000 (13:01 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 13:01:45 +0000 (13:01 +0000)
(diagnostic_report_diagnostic): Don't handle plugins specially
here.  Pass context to internal_error callback.
* diagnostic.h (struct diagnostic_context): Add context parameter
to internal_error callback.
* plugin.c (warn_if_plugins, plugins_internal_error_function):
New.
* plugin.h (struct diagnostic_context): Declare.
(warn_if_plugins, plugins_internal_error_function): Declare.
* toplev.c (general_init): Set global_dc->internal_error.
* Makefile.in (diagnostic.o): Update dependencies.

ada:
* gcc-interface/misc.c (internal_error_function): Add context
parameter.  Use it to access show_column flag and instead of using
global_dc.  Call warn_if_plugins.
* gcc-interface/Make-lang.in (ada/misc.o): Update dependencies.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159819 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/ada/ChangeLog
gcc/ada/gcc-interface/Make-lang.in
gcc/ada/gcc-interface/misc.c
gcc/diagnostic.c
gcc/diagnostic.h
gcc/plugin.c
gcc/plugin.h
gcc/toplev.c

index 7d186a6..7ece57b 100644 (file)
@@ -1,3 +1,17 @@
+2010-05-25  Joseph Myers  <joseph@codesourcery.com>
+
+       * diagnostic.c: Don't include plugin.h.
+       (diagnostic_report_diagnostic): Don't handle plugins specially
+       here.  Pass context to internal_error callback.
+       * diagnostic.h (struct diagnostic_context): Add context parameter
+       to internal_error callback.
+       * plugin.c (warn_if_plugins, plugins_internal_error_function):
+       New.
+       * plugin.h (struct diagnostic_context): Declare.
+       (warn_if_plugins, plugins_internal_error_function): Declare.
+       * toplev.c (general_init): Set global_dc->internal_error.
+       * Makefile.in (diagnostic.o): Update dependencies.
+
 2010-05-25 Iain Sandoe  <iains@gcc.gnu.org>
 
        * config/rs6000/darwin64.h: Update DARWIN_ARCH_SPEC.
index 8f44881..f9926fa 100644 (file)
@@ -2735,7 +2735,7 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(GIMPLE_H) realmpfr.h
 diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    version.h $(INPUT_H) $(TOPLEV_H) intl.h $(DIAGNOSTIC_H) \
-   diagnostic.def opts.h $(PLUGIN_H)
+   diagnostic.def opts.h
 opts.o : opts.c opts.h options.h $(TOPLEV_H) $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_H) $(TM_H) langhooks.h $(GGC_H) $(EXPR_H) $(RTL_H) \
    output.h $(DIAGNOSTIC_H) $(TM_P_H) $(INSN_ATTR_H) intl.h $(TARGET_H) \
index d5aa53a..7e1d62d 100644 (file)
@@ -1,3 +1,10 @@
+2010-05-25  Joseph Myers  <joseph@codesourcery.com>
+
+       * gcc-interface/misc.c (internal_error_function): Add context
+       parameter.  Use it to access show_column flag and instead of using
+       global_dc.  Call warn_if_plugins.
+       * gcc-interface/Make-lang.in (ada/misc.o): Update dependencies.
+
 2010-05-19  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/misc.c (LANG_HOOKS_DEEP_UNSHARING): Redefine.
index 25c0964..43a3cec 100644 (file)
@@ -1235,7 +1235,7 @@ ada/decl.o : ada/gcc-interface/decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
 ada/misc.o : ada/gcc-interface/misc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(TREE_H) $(DIAGNOSTIC_H) $(TARGET_H) $(EXPR_H) libfuncs.h \
    $(FLAGS_H) debug.h $(CGRAPH_H) $(OPTABS_H) toplev.h except.h langhooks.h \
-   $(LANGHOOKS_DEF_H) opts.h options.h $(TREE_INLINE_H) \
+   $(LANGHOOKS_DEF_H) opts.h options.h $(TREE_INLINE_H) $(PLUGIN_H) \
    ada/gcc-interface/ada.h ada/adadecode.h ada/types.h ada/atree.h \
    ada/elists.h ada/namet.h ada/nlists.h ada/stringt.h ada/uintp.h ada/fe.h \
    ada/sinfo.h ada/einfo.h $(ADA_TREE_H) ada/gcc-interface/gigi.h \
index dba6dca..22826ed 100644 (file)
@@ -48,6 +48,7 @@
 #include "opts.h"
 #include "options.h"
 #include "tree-inline.h"
+#include "plugin.h"
 
 #include "ada.h"
 #include "adadecode.h"
@@ -75,7 +76,8 @@ static const char *gnat_printable_name        (tree, int);
 static const char *gnat_dwarf_name     (tree, int);
 static tree gnat_return_tree           (tree);
 static void gnat_parse_file            (int);
-static void internal_error_function    (const char *, va_list *);
+static void internal_error_function    (diagnostic_context *,
+                                        const char *, va_list *);
 static tree gnat_type_max_size         (const_tree);
 static void gnat_get_subrange_bounds   (const_tree, tree *, tree *);
 static tree gnat_eh_personality                (void);
@@ -334,7 +336,8 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
 /* Here is the function to handle the compiler error processing in GCC.  */
 
 static void
-internal_error_function (const char *msgid, va_list *ap)
+internal_error_function (diagnostic_context *context,
+                        const char *msgid, va_list *ap)
 {
   text_info tinfo;
   char *buffer, *p, *loc;
@@ -342,17 +345,20 @@ internal_error_function (const char *msgid, va_list *ap)
   Fat_Pointer fp, fp_loc;
   expanded_location s;
 
+  /* Warn if plugins present.  */
+  warn_if_plugins ();
+
   /* Reset the pretty-printer.  */
-  pp_clear_output_area (global_dc->printer);
+  pp_clear_output_area (context->printer);
 
   /* Format the message into the pretty-printer.  */
   tinfo.format_spec = msgid;
   tinfo.args_ptr = ap;
   tinfo.err_no = errno;
-  pp_format_verbatim (global_dc->printer, &tinfo);
+  pp_format_verbatim (context->printer, &tinfo);
 
   /* Extract a (writable) pointer to the formatted text.  */
-  buffer = xstrdup (pp_formatted_text (global_dc->printer));
+  buffer = xstrdup (pp_formatted_text (context->printer));
 
   /* Go up to the first newline.  */
   for (p = buffer; *p; p++)
@@ -368,7 +374,7 @@ internal_error_function (const char *msgid, va_list *ap)
   fp.Array = buffer;
 
   s = expand_location (input_location);
-  if (flag_show_column && s.column != 0)
+  if (context->show_column && s.column != 0)
     asprintf (&loc, "%s:%d:%d", s.file, s.line, s.column);
   else
     asprintf (&loc, "%s:%d", s.file, s.line);
index 7757ace..c16ec7c 100644 (file)
@@ -32,7 +32,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "intl.h"
 #include "diagnostic.h"
 #include "opts.h"
-#include "plugin.h"
 
 #define pedantic_warning_kind(DC)                      \
   ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
@@ -380,14 +379,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 
   context->lock++;
 
-  if (diagnostic->kind == DK_ICE && plugins_active_p ())
-    {
-      fnotice (stderr, "*** WARNING *** there are active plugins, do not report"
-              " this as a bug unless you can reproduce it without enabling"
-              " any plugins.\n");
-      dump_active_plugins (stderr);
-    }
-
   if (diagnostic->kind == DK_ICE)
     {
 #ifndef ENABLE_CHECKING
@@ -405,7 +396,8 @@ diagnostic_report_diagnostic (diagnostic_context *context,
        }
 #endif
       if (context->internal_error)
-       (*context->internal_error) (diagnostic->message.format_spec,
+       (*context->internal_error) (context,
+                                   diagnostic->message.format_spec,
                                    diagnostic->message.args_ptr);
     }
   ++diagnostic_kind_count (context, diagnostic->kind);
index 1db91c2..9fd508b 100644 (file)
@@ -112,7 +112,7 @@ struct diagnostic_context
   diagnostic_finalizer_fn end_diagnostic;
 
   /* Client hook to report an internal error.  */
-  void (*internal_error) (const char *, va_list *);
+  void (*internal_error) (diagnostic_context *, const char *, va_list *);
 
   /* Auxiliary data for client.  */
   void *x_data;
index 707d2dd..1c737a5 100644 (file)
@@ -810,6 +810,32 @@ debug_active_plugins (void)
   dump_active_plugins (stderr);
 }
 
+/* Give a warning if plugins are present, before an ICE message asking
+   to submit a bug report.  */
+
+void
+warn_if_plugins (void)
+{
+  if (plugins_active_p ())
+    {
+      fnotice (stderr, "*** WARNING *** there are active plugins, do not report"
+              " this as a bug unless you can reproduce it without enabling"
+              " any plugins.\n");
+      dump_active_plugins (stderr);
+    }
+
+}
+
+/* Likewise, as a callback from the diagnostics code.  */
+
+void
+plugins_internal_error_function (struct diagnostic_context *context ATTRIBUTE_UNUSED,
+                                const char *msgid ATTRIBUTE_UNUSED,
+                                va_list *ap ATTRIBUTE_UNUSED)
+{
+  warn_if_plugins ();
+}
+
 /* The default version check. Compares every field in VERSION. */
 
 bool
index 3269641..ec04203 100644 (file)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gcc-plugin.h"
 
 struct attribute_spec;
+struct diagnostic_context;
 
 extern void add_new_plugin (const char *);
 extern void parse_plugin_arg_opt (const char *);
@@ -31,6 +32,9 @@ extern void initialize_plugins (void);
 extern bool plugins_active_p (void);
 extern void dump_active_plugins (FILE *);
 extern void debug_active_plugins (void);
+extern void warn_if_plugins (void);
+extern void plugins_internal_error_function (struct diagnostic_context *,
+                                            const char *, va_list *);
 extern void print_plugins_versions (FILE *file, const char *indent);
 extern void print_plugins_help (FILE *file, const char *indent);
 extern void finalize_plugins (void);
index 9d3396b..aa3eff3 100644 (file)
@@ -1697,6 +1697,7 @@ general_init (const char *argv0)
      override it later.  */
   pp_format_decoder (global_dc->printer) = &default_tree_printer;
   global_dc->show_option_requested = flag_diagnostics_show_option;
+  global_dc->internal_error = plugins_internal_error_function;
 
   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
 #ifdef SIGSEGV