* diagnostic.c: Don't include flags.h.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2010 18:55:44 +0000 (18:55 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2010 18:55:44 +0000 (18:55 +0000)
(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.

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

gcc/ChangeLog
gcc/Makefile.in
gcc/cp/ChangeLog
gcc/cp/error.c
gcc/diagnostic.c
gcc/diagnostic.h
gcc/langhooks.c
gcc/toplev.c
gcc/tree-diagnostic.c

index def777d..8806178 100644 (file)
@@ -1,3 +1,32 @@
+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>
 
        * config/i386/ia32intrin.h (__crc32q): Define only if
index 7f5eba2..ef7a324 100644 (file)
@@ -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) \
    $(GIMPLE_H) realmpfr.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)
 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) \
index 2a3a8a0..74cb213 100644 (file)
@@ -1,3 +1,11 @@
+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>
 
        PR c++/41510
index dcdfe89..592f360 100644 (file)
@@ -2550,7 +2550,8 @@ cp_diagnostic_starter (diagnostic_context *context,
   diagnostic_report_current_module (context);
   cp_print_error_function (context, diagnostic);
   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
@@ -2644,7 +2645,7 @@ cp_print_error_function (diagnostic_context *context,
                  pp_base_newline (context->printer);
                  if (s.file != NULL)
                    {
-                     if (flag_show_column && s.column != 0)
+                     if (context->show_column && s.column != 0)
                        pp_printf (context->printer,
                                   _("    inlined from %qs at %s:%d:%d"),
                                   cxx_printable_name_translate (fndecl, 2),
@@ -2750,7 +2751,7 @@ print_instantiation_partial_context_line (diagnostic_context *context,
       const char *str;
       str = decl_as_string_translate (t->decl,
                                      TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
-      if (flag_show_column)
+      if (context->show_column)
        pp_verbatim (context->printer,
                     recursive_p
                     ? _("%s:%d:%d:   recursively instantiated from %qs\n")
@@ -2765,7 +2766,7 @@ print_instantiation_partial_context_line (diagnostic_context *context,
     }
   else
     {
-      if (flag_show_column)
+      if (context->show_column)
        pp_verbatim (context->printer, 
                     recursive_p
                     ? _("%s:%d:%d:   recursively instantiated from here")
@@ -2816,7 +2817,7 @@ print_instantiation_partial_context (diagnostic_context *context,
        {
          expanded_location xloc;
          xloc = expand_location (loc);
-         if (flag_show_column)
+         if (context->show_column)
            pp_verbatim (context->printer,
                         _("%s:%d:%d:   [ skipping %d instantiation contexts ]\n"),
                         xloc.file, xloc.line, xloc.column, skip);
index eee97ce..7757ace 100644 (file)
@@ -27,7 +27,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "version.h"
-#include "flags.h"
 #include "input.h"
 #include "toplev.h"
 #include "intl.h"
@@ -35,8 +34,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "plugin.h"
 
-#define pedantic_warning_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
-#define permissive_error_kind() (flag_permissive ? DK_WARNING : DK_ERROR)
+#define pedantic_warning_kind(DC)                      \
+  ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
+#define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
 
 /* Prototypes.  */
 static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
@@ -156,7 +156,8 @@ diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid,
 /* Return a malloc'd string describing a location.  The caller is
    responsible for freeing the memory.  */
 char *
-diagnostic_build_prefix (diagnostic_info *diagnostic)
+diagnostic_build_prefix (diagnostic_context *context,
+                        diagnostic_info *diagnostic)
 {
   static const char *const diagnostic_kind_text[] = {
 #define DEFINE_DIAGNOSTIC_KIND(K, T) (T),
@@ -173,7 +174,7 @@ diagnostic_build_prefix (diagnostic_info *diagnostic)
   return
     (s.file == NULL
      ? 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: %s", s.file, s.line, text));
 }
@@ -196,7 +197,7 @@ diagnostic_action_after_output (diagnostic_context *context,
     case DK_SORRY:
       if (context->abort_on_error)
        real_abort ();
-      if (flag_fatal_errors)
+      if (context->fatal_errors)
        {
          fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
          diagnostic_finish (context);
@@ -246,7 +247,7 @@ diagnostic_report_current_module (diagnostic_context *context)
       if (! MAIN_FILE_P (map))
        {
          map = INCLUDED_FROM (line_table, map);
-         if (flag_show_column)
+         if (context->show_column)
            pp_verbatim (context->printer,
                         "In file included from %s:%d:%d",
                         map->to_file,
@@ -273,7 +274,8 @@ default_diagnostic_starter (diagnostic_context *context,
                            diagnostic_info *diagnostic)
 {
   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
@@ -326,7 +328,7 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 
   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.  */
       orig_diag_kind = diagnostic->kind;
     }
@@ -524,7 +526,7 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt,
   if (kind == DK_PERMERROR)
     {
       diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
-                          permissive_error_kind ());
+                          permissive_error_kind (global_dc));
       diagnostic.option_index = OPT_fpermissive;
     }
   else {
@@ -643,7 +645,7 @@ permerror (location_t location, const char *gmsgid, ...)
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
-                       permissive_error_kind ());
+                       permissive_error_kind (global_dc));
   diagnostic.option_index = OPT_fpermissive;
   va_end (ap);
   return report_diagnostic (&diagnostic);
index 89c1271..1db91c2 100644 (file)
@@ -87,6 +87,18 @@ struct diagnostic_context
   /* True if we should raise a SIGABRT on errors.  */
   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
      responsible for preparing message prefix and such.  For example, it
      might say:
@@ -211,7 +223,7 @@ extern void diagnostic_set_info_translated (diagnostic_info *, const char *,
 extern bool emit_diagnostic (diagnostic_t, location_t, int,
                             const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
 #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_finalizer (diagnostic_context *, diagnostic_info *);
 
index 37baa27..bdda623 100644 (file)
@@ -426,7 +426,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
                  pp_newline (context->printer);
                  if (s.file != NULL)
                    {
-                     if (flag_show_column)
+                     if (context->show_column)
                        pp_printf (context->printer,
                                   _("    inlined from %qs at %s:%d:%d"),
                                   identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
index fcd720d..9d3396b 100644 (file)
@@ -1827,6 +1827,11 @@ process_options (void)
   if (flag_compare_debug) 
     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 ())
     {
       warning (OPT_fsection_anchors,
index 76fd129..b456a2a 100644 (file)
@@ -44,5 +44,6 @@ default_tree_diagnostic_starter (diagnostic_context *context,
                                 diagnostic_info *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));
 }