Commit 243fbddd by Joseph Myers Committed by Joseph Myers

diagnostic.c: Don't include flags.h.

	* diagnostic.c: Don't include flags.h.
	(pedantic_warning_kind, permissive_error_kind): Take diagnostic
	context parameters.  Check flags in the context passed as a
	parameter.
	(diagnostic_build_prefix): Add context parameter.  Check
	show_column flag in context.
	(diagnostic_action_after_output): Check fatal_errors flag in
	context.
	(diagnostic_report_current_module): Check show_column flag in
	context.
	(default_diagnostic_starter): Update call to
	diagnostic_build_prefix.
	(diagnostic_report_diagnostic): Pass context to
	pedantic_warning_kind.
	(emit_diagnostic): Pass context to permissive_error_kind.
	(permerror): Pass context to permissive_error_kind.
	* diagnostic.h (struct diagnostic_context): Add show_column,
	pedantic_errors, permissive and fatal_errors fields.
	(diagnostic_build_prefix): Update prototype.
	* langhooks.c
	* toplev.c (process_options): Set flags in global_dc from
	flag_show_column, flag_pedantic_errors, flag_permissive,
	flag_fatal_errors.
	* tree-diagnostic.c (default_tree_diagnostic_starter): Update call
	to diagnostic_build_prefix.
	* Makefile.in (diagnostic.o): Update dependencies.

cp:
	* error.c (cp_diagnostic_starter): Update call to
	diagnostic_build_prefix.
	(cp_print_error_function,
	print_instantiation_partial_context_line): Check show_column flag
	in context.

From-SVN: r159793
parent 611d6f76
2010-05-24 Joseph Myers <joseph@codesourcery.com>
* diagnostic.c: Don't include flags.h.
(pedantic_warning_kind, permissive_error_kind): Take diagnostic
context parameters. Check flags in the context passed as a
parameter.
(diagnostic_build_prefix): Add context parameter. Check
show_column flag in context.
(diagnostic_action_after_output): Check fatal_errors flag in
context.
(diagnostic_report_current_module): Check show_column flag in
context.
(default_diagnostic_starter): Update call to
diagnostic_build_prefix.
(diagnostic_report_diagnostic): Pass context to
pedantic_warning_kind.
(emit_diagnostic): Pass context to permissive_error_kind.
(permerror): Pass context to permissive_error_kind.
* diagnostic.h (struct diagnostic_context): Add show_column,
pedantic_errors, permissive and fatal_errors fields.
(diagnostic_build_prefix): Update prototype.
* langhooks.c
* toplev.c (process_options): Set flags in global_dc from
flag_show_column, flag_pedantic_errors, flag_permissive,
flag_fatal_errors.
* tree-diagnostic.c (default_tree_diagnostic_starter): Update call
to diagnostic_build_prefix.
* Makefile.in (diagnostic.o): Update dependencies.
2010-05-24 H.J. Lu <hongjiu.lu@intel.com> 2010-05-24 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/ia32intrin.h (__crc32q): Define only if * config/i386/ia32intrin.h (__crc32q): Define only if
......
...@@ -2735,7 +2735,7 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ ...@@ -2735,7 +2735,7 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(GGC_H) $(TM_P_H) langhooks.h $(MD5_H) intl.h $(TARGET_H) \ $(GGC_H) $(TM_P_H) langhooks.h $(MD5_H) intl.h $(TARGET_H) \
$(GIMPLE_H) realmpfr.h $(GIMPLE_H) realmpfr.h
diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
version.h $(FLAGS_H) $(INPUT_H) $(TOPLEV_H) intl.h $(DIAGNOSTIC_H) \ version.h $(INPUT_H) $(TOPLEV_H) intl.h $(DIAGNOSTIC_H) \
diagnostic.def opts.h $(PLUGIN_H) diagnostic.def opts.h $(PLUGIN_H)
opts.o : opts.c opts.h options.h $(TOPLEV_H) $(CONFIG_H) $(SYSTEM_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) \ coretypes.h $(TREE_H) $(TM_H) langhooks.h $(GGC_H) $(EXPR_H) $(RTL_H) \
......
2010-05-24 Joseph Myers <joseph@codesourcery.com>
* error.c (cp_diagnostic_starter): Update call to
diagnostic_build_prefix.
(cp_print_error_function,
print_instantiation_partial_context_line): Check show_column flag
in context.
2010-05-24 Jason Merrill <jason@redhat.com> 2010-05-24 Jason Merrill <jason@redhat.com>
PR c++/41510 PR c++/41510
......
...@@ -2550,7 +2550,8 @@ cp_diagnostic_starter (diagnostic_context *context, ...@@ -2550,7 +2550,8 @@ cp_diagnostic_starter (diagnostic_context *context,
diagnostic_report_current_module (context); diagnostic_report_current_module (context);
cp_print_error_function (context, diagnostic); cp_print_error_function (context, diagnostic);
maybe_print_instantiation_context (context); maybe_print_instantiation_context (context);
pp_base_set_prefix (context->printer, diagnostic_build_prefix (diagnostic)); pp_base_set_prefix (context->printer, diagnostic_build_prefix (context,
diagnostic));
} }
static void static void
...@@ -2644,7 +2645,7 @@ cp_print_error_function (diagnostic_context *context, ...@@ -2644,7 +2645,7 @@ cp_print_error_function (diagnostic_context *context,
pp_base_newline (context->printer); pp_base_newline (context->printer);
if (s.file != NULL) if (s.file != NULL)
{ {
if (flag_show_column && s.column != 0) if (context->show_column && s.column != 0)
pp_printf (context->printer, pp_printf (context->printer,
_(" inlined from %qs at %s:%d:%d"), _(" inlined from %qs at %s:%d:%d"),
cxx_printable_name_translate (fndecl, 2), cxx_printable_name_translate (fndecl, 2),
...@@ -2750,7 +2751,7 @@ print_instantiation_partial_context_line (diagnostic_context *context, ...@@ -2750,7 +2751,7 @@ print_instantiation_partial_context_line (diagnostic_context *context,
const char *str; const char *str;
str = decl_as_string_translate (t->decl, str = decl_as_string_translate (t->decl,
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE); TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
if (flag_show_column) if (context->show_column)
pp_verbatim (context->printer, pp_verbatim (context->printer,
recursive_p recursive_p
? _("%s:%d:%d: recursively instantiated from %qs\n") ? _("%s:%d:%d: recursively instantiated from %qs\n")
...@@ -2765,7 +2766,7 @@ print_instantiation_partial_context_line (diagnostic_context *context, ...@@ -2765,7 +2766,7 @@ print_instantiation_partial_context_line (diagnostic_context *context,
} }
else else
{ {
if (flag_show_column) if (context->show_column)
pp_verbatim (context->printer, pp_verbatim (context->printer,
recursive_p recursive_p
? _("%s:%d:%d: recursively instantiated from here") ? _("%s:%d:%d: recursively instantiated from here")
...@@ -2816,7 +2817,7 @@ print_instantiation_partial_context (diagnostic_context *context, ...@@ -2816,7 +2817,7 @@ print_instantiation_partial_context (diagnostic_context *context,
{ {
expanded_location xloc; expanded_location xloc;
xloc = expand_location (loc); xloc = expand_location (loc);
if (flag_show_column) if (context->show_column)
pp_verbatim (context->printer, pp_verbatim (context->printer,
_("%s:%d:%d: [ skipping %d instantiation contexts ]\n"), _("%s:%d:%d: [ skipping %d instantiation contexts ]\n"),
xloc.file, xloc.line, xloc.column, skip); xloc.file, xloc.line, xloc.column, skip);
......
...@@ -27,7 +27,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -27,7 +27,6 @@ along with GCC; see the file COPYING3. If not see
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "version.h" #include "version.h"
#include "flags.h"
#include "input.h" #include "input.h"
#include "toplev.h" #include "toplev.h"
#include "intl.h" #include "intl.h"
...@@ -35,8 +34,9 @@ along with GCC; see the file COPYING3. If not see ...@@ -35,8 +34,9 @@ along with GCC; see the file COPYING3. If not see
#include "opts.h" #include "opts.h"
#include "plugin.h" #include "plugin.h"
#define pedantic_warning_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING) #define pedantic_warning_kind(DC) \
#define permissive_error_kind() (flag_permissive ? DK_WARNING : DK_ERROR) ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
#define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
/* Prototypes. */ /* Prototypes. */
static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1; static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
...@@ -156,7 +156,8 @@ diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid, ...@@ -156,7 +156,8 @@ diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid,
/* Return a malloc'd string describing a location. The caller is /* Return a malloc'd string describing a location. The caller is
responsible for freeing the memory. */ responsible for freeing the memory. */
char * char *
diagnostic_build_prefix (diagnostic_info *diagnostic) diagnostic_build_prefix (diagnostic_context *context,
diagnostic_info *diagnostic)
{ {
static const char *const diagnostic_kind_text[] = { static const char *const diagnostic_kind_text[] = {
#define DEFINE_DIAGNOSTIC_KIND(K, T) (T), #define DEFINE_DIAGNOSTIC_KIND(K, T) (T),
...@@ -173,7 +174,7 @@ diagnostic_build_prefix (diagnostic_info *diagnostic) ...@@ -173,7 +174,7 @@ diagnostic_build_prefix (diagnostic_info *diagnostic)
return return
(s.file == NULL (s.file == NULL
? build_message_string ("%s: %s", progname, text) ? build_message_string ("%s: %s", progname, text)
: flag_show_column : context->show_column
? build_message_string ("%s:%d:%d: %s", s.file, s.line, s.column, text) ? build_message_string ("%s:%d:%d: %s", s.file, s.line, s.column, text)
: build_message_string ("%s:%d: %s", s.file, s.line, text)); : build_message_string ("%s:%d: %s", s.file, s.line, text));
} }
...@@ -196,7 +197,7 @@ diagnostic_action_after_output (diagnostic_context *context, ...@@ -196,7 +197,7 @@ diagnostic_action_after_output (diagnostic_context *context,
case DK_SORRY: case DK_SORRY:
if (context->abort_on_error) if (context->abort_on_error)
real_abort (); real_abort ();
if (flag_fatal_errors) if (context->fatal_errors)
{ {
fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n"); fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
diagnostic_finish (context); diagnostic_finish (context);
...@@ -246,7 +247,7 @@ diagnostic_report_current_module (diagnostic_context *context) ...@@ -246,7 +247,7 @@ diagnostic_report_current_module (diagnostic_context *context)
if (! MAIN_FILE_P (map)) if (! MAIN_FILE_P (map))
{ {
map = INCLUDED_FROM (line_table, map); map = INCLUDED_FROM (line_table, map);
if (flag_show_column) if (context->show_column)
pp_verbatim (context->printer, pp_verbatim (context->printer,
"In file included from %s:%d:%d", "In file included from %s:%d:%d",
map->to_file, map->to_file,
...@@ -273,7 +274,8 @@ default_diagnostic_starter (diagnostic_context *context, ...@@ -273,7 +274,8 @@ default_diagnostic_starter (diagnostic_context *context,
diagnostic_info *diagnostic) diagnostic_info *diagnostic)
{ {
diagnostic_report_current_module (context); diagnostic_report_current_module (context);
pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic)); pp_set_prefix (context->printer, diagnostic_build_prefix (context,
diagnostic));
} }
void void
...@@ -326,7 +328,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, ...@@ -326,7 +328,7 @@ diagnostic_report_diagnostic (diagnostic_context *context,
if (diagnostic->kind == DK_PEDWARN) if (diagnostic->kind == DK_PEDWARN)
{ {
diagnostic->kind = pedantic_warning_kind (); diagnostic->kind = pedantic_warning_kind (context);
/* We do this to avoid giving the message for -pedantic-errors. */ /* We do this to avoid giving the message for -pedantic-errors. */
orig_diag_kind = diagnostic->kind; orig_diag_kind = diagnostic->kind;
} }
...@@ -524,7 +526,7 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt, ...@@ -524,7 +526,7 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt,
if (kind == DK_PERMERROR) if (kind == DK_PERMERROR)
{ {
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
permissive_error_kind ()); permissive_error_kind (global_dc));
diagnostic.option_index = OPT_fpermissive; diagnostic.option_index = OPT_fpermissive;
} }
else { else {
...@@ -643,7 +645,7 @@ permerror (location_t location, const char *gmsgid, ...) ...@@ -643,7 +645,7 @@ permerror (location_t location, const char *gmsgid, ...)
va_start (ap, gmsgid); va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
permissive_error_kind ()); permissive_error_kind (global_dc));
diagnostic.option_index = OPT_fpermissive; diagnostic.option_index = OPT_fpermissive;
va_end (ap); va_end (ap);
return report_diagnostic (&diagnostic); return report_diagnostic (&diagnostic);
......
...@@ -87,6 +87,18 @@ struct diagnostic_context ...@@ -87,6 +87,18 @@ struct diagnostic_context
/* True if we should raise a SIGABRT on errors. */ /* True if we should raise a SIGABRT on errors. */
bool abort_on_error; bool abort_on_error;
/* True if we should show the column number on diagnostics. */
bool show_column;
/* True if pedwarns are errors. */
bool pedantic_errors;
/* True if permerrors are warnings. */
bool permissive;
/* True if errors are fatal. */
bool fatal_errors;
/* This function is called before any message is printed out. It is /* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it responsible for preparing message prefix and such. For example, it
might say: might say:
...@@ -211,7 +223,7 @@ extern void diagnostic_set_info_translated (diagnostic_info *, const char *, ...@@ -211,7 +223,7 @@ extern void diagnostic_set_info_translated (diagnostic_info *, const char *,
extern bool emit_diagnostic (diagnostic_t, location_t, int, extern bool emit_diagnostic (diagnostic_t, location_t, int,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
#endif #endif
extern char *diagnostic_build_prefix (diagnostic_info *); extern char *diagnostic_build_prefix (diagnostic_context *, diagnostic_info *);
void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); void default_diagnostic_starter (diagnostic_context *, diagnostic_info *);
void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
......
...@@ -426,7 +426,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file, ...@@ -426,7 +426,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
pp_newline (context->printer); pp_newline (context->printer);
if (s.file != NULL) if (s.file != NULL)
{ {
if (flag_show_column) if (context->show_column)
pp_printf (context->printer, pp_printf (context->printer,
_(" inlined from %qs at %s:%d:%d"), _(" inlined from %qs at %s:%d:%d"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
......
...@@ -1827,6 +1827,11 @@ process_options (void) ...@@ -1827,6 +1827,11 @@ process_options (void)
if (flag_compare_debug) if (flag_compare_debug)
diagnostic_inhibit_notes (global_dc); diagnostic_inhibit_notes (global_dc);
global_dc->show_column = flag_show_column;
global_dc->pedantic_errors = flag_pedantic_errors;
global_dc->permissive = flag_permissive;
global_dc->fatal_errors = flag_fatal_errors;
if (flag_section_anchors && !target_supports_section_anchors_p ()) if (flag_section_anchors && !target_supports_section_anchors_p ())
{ {
warning (OPT_fsection_anchors, warning (OPT_fsection_anchors,
......
...@@ -44,5 +44,6 @@ default_tree_diagnostic_starter (diagnostic_context *context, ...@@ -44,5 +44,6 @@ default_tree_diagnostic_starter (diagnostic_context *context,
diagnostic_info *diagnostic) diagnostic_info *diagnostic)
{ {
diagnostic_report_current_function (context, diagnostic); diagnostic_report_current_function (context, diagnostic);
pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic)); pp_set_prefix (context->printer, diagnostic_build_prefix (context,
diagnostic));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment