Skip to content

Commit

Permalink
* diagnostic.c: Don't include plugin.h.
Browse files Browse the repository at this point in the history
	(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
  • Loading branch information
jsm28 committed May 25, 2010
1 parent 78eee48 commit 1f63d33
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 19 deletions.
14 changes: 14 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gcc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
7 changes: 7 additions & 0 deletions gcc/ada/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gcc/ada/gcc-interface/Make-lang.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
18 changes: 12 additions & 6 deletions gcc/ada/gcc-interface/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "opts.h"
#include "options.h"
#include "tree-inline.h"
#include "plugin.h"

#include "ada.h"
#include "adadecode.h"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -334,25 +336,29 @@ 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;
String_Template temp, temp_loc;
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++)
Expand All @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions gcc/diagnostic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gcc/diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions gcc/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions gcc/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions gcc/toplev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f63d33

Please sign in to comment.