This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C/C++/Fortran] remove pedwarn0 and warning0 and fix PR 36901


2008/8/4 Joseph S. Myers <joseph@codesourcery.com>:
> On Mon, 4 Aug 2008, Manuel López-Ibáñez wrote:
>
>> * locate_old_decl now always prints "note: previous definition of %q+D
>> was here" instead of "error:" or "warning:".
>
> This function should no longer need the G_ in the inform calls that it did
> when they were calls through a function pointer: inform is declared with a
> parameter called gmsgid so these strings should be automatically extracted
> for translation.

Updated patch. Bootstrapped and regression tested using Paolo's patch
with no new failures.

The Changelog is the same as in the original patch.

OK for trunk?

Cheers,

Manuel.
Index: gcc/diagnostic.def
===================================================================
--- gcc/diagnostic.def	(revision 138312)
+++ gcc/diagnostic.def	(working copy)
@@ -18,6 +18,10 @@ DEFINE_DIAGNOSTIC_KIND (DK_ERROR, "error
 DEFINE_DIAGNOSTIC_KIND (DK_SORRY, "sorry, unimplemented: ")
 DEFINE_DIAGNOSTIC_KIND (DK_WARNING, "warning: ")
 DEFINE_DIAGNOSTIC_KIND (DK_ANACHRONISM, "anachronism: ")
 DEFINE_DIAGNOSTIC_KIND (DK_NOTE, "note: ")
 DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug: ")
+/* These two would be re-classified as DK_WARNING or DK_ERROR, so the
+prefix does not matter.  */
+DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
+DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")
 
Index: gcc/diagnostic.c
===================================================================
--- gcc/diagnostic.c	(revision 138312)
+++ gcc/diagnostic.c	(working copy)
@@ -39,10 +39,12 @@ along with GCC; see the file COPYING3.  
 #include "diagnostic.h"
 #include "langhooks.h"
 #include "langhooks-def.h"
 #include "opts.h"
 
+#define pedantic_warning_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
+#define permissive_error_kind() (flag_permissive ? DK_WARNING : DK_ERROR)
 
 /* Prototypes.  */
 static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
 
 static void default_diagnostic_starter (diagnostic_context *,
@@ -291,25 +293,29 @@ diagnostic_classify_diagnostic (diagnost
 
 /* Report a diagnostic message (an error or a warning) as specified by
    DC.  This function is *the* subroutine in terms of which front-ends
    should implement their specific diagnostic handling modules.  The
    front-end independent format specifiers are exactly those described
-   in the documentation of output_format.  */
+   in the documentation of output_format.  
+   Return true if a diagnostic was printed, false otherwise.  */
 
-void
+bool
 diagnostic_report_diagnostic (diagnostic_context *context,
 			      diagnostic_info *diagnostic)
 {
   location_t location = diagnostic->location;
   bool maybe_print_warnings_as_errors_message = false;
   const char *saved_format_spec;
 
   /* Give preference to being able to inhibit warnings, before they
      get reclassified to something else.  */
-  if (diagnostic->kind == DK_WARNING 
+  if ((diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN)
       && !diagnostic_report_warnings_p (location))
-    return;
+    return false;
+
+  if (diagnostic->kind == DK_PEDWARN) 
+    diagnostic->kind = pedantic_warning_kind ();
   
   if (context->lock > 0)
     {
       /* If we're reporting an ICE in the middle of some other error,
 	 try to flush out the previous error, then let this one
@@ -334,22 +340,22 @@ diagnostic_report_diagnostic (diagnostic
   if (diagnostic->option_index)
     {
       /* This tests if the user provided the appropriate -Wfoo or
 	 -Wno-foo option.  */
       if (! option_enabled (diagnostic->option_index))
-	return;
+	return false;
       /* This tests if the user provided the appropriate -Werror=foo
 	 option.  */
       if (context->classify_diagnostic[diagnostic->option_index] != DK_UNSPECIFIED)
 	{
 	  diagnostic->kind = context->classify_diagnostic[diagnostic->option_index];
 	  maybe_print_warnings_as_errors_message = false;
 	}
       /* This allows for future extensions, like temporarily disabling
 	 warnings for ranges of source code.  */
       if (diagnostic->kind == DK_IGNORED)
-	return;
+	return false;
     }
 
   /* If we changed the kind due to -Werror, and didn't override it, we
      need to print this message.  */
   if (context->issue_warnings_are_errors_message
@@ -401,10 +407,12 @@ diagnostic_report_diagnostic (diagnostic
   diagnostic_action_after_output (context, diagnostic);
   diagnostic->message.format_spec = saved_format_spec;
   diagnostic->abstract_origin = NULL;
 
   context->lock--;
+
+  return true;
 }
 
 /* Given a partial pathname as input, return another pathname that
    shares no directory elements with the pathname of __FILE__.  This
    is used by fancy_abort() to print `Internal compiler error in expr.c'
@@ -455,66 +463,80 @@ verbatim (const char *gmsgid, ...)
   pp_format_verbatim (global_dc->printer, &text);
   pp_flush (global_dc->printer);
   va_end (ap);
 }
 
-/* An informative note.  Use this for additional details on an error
-   message.  */
-void
-inform (const char *gmsgid, ...)
+bool
+emit_diagnostic (diagnostic_t kind, location_t location, int opt, 
+		 const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
-  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_NOTE);
-  report_diagnostic (&diagnostic);
+  if (kind == DK_PERMERROR)
+    {
+      diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
+			   permissive_error_kind ());
+      diagnostic.option_index = OPT_fpermissive;
+    }
+  else {
+      diagnostic_set_info (&diagnostic, gmsgid, &ap, location, kind);
+      if (kind == DK_WARNING || kind == DK_PEDWARN)
+	diagnostic.option_index = opt;
+  }
   va_end (ap);
+
+  return report_diagnostic (&diagnostic);
 }
 
-/* A warning at INPUT_LOCATION.  Use this for code which is correct according
-   to the relevant language specification but is likely to be buggy anyway.  */
+/* An informative note.  Use this for additional details on an error
+   message.  */
 void
-warning (int opt, const char *gmsgid, ...)
+inform (const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
-  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_WARNING);
-  diagnostic.option_index = opt;
-
+  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_NOTE);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
-void
-warning0 (const char *gmsgid, ...)
+/* A warning at INPUT_LOCATION.  Use this for code which is correct according
+   to the relevant language specification but is likely to be buggy anyway.  
+   Returns true if the warning was printed, false if it was inhibited.  */
+bool
+warning (int opt, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_WARNING);
-  report_diagnostic (&diagnostic);
+  diagnostic.option_index = opt;
+
   va_end (ap);
+  return report_diagnostic (&diagnostic);
 }
 
 /* A warning at LOCATION.  Use this for code which is correct according to the
-   relevant language specification but is likely to be buggy anyway.  */
-void
+   relevant language specification but is likely to be buggy anyway.
+   Returns true if the warning was printed, false if it was inhibited.  */
+
+bool
 warning_at (location_t location, int opt, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING);
   diagnostic.option_index = opt;
-
-  report_diagnostic (&diagnostic);
   va_end (ap);
+  return report_diagnostic (&diagnostic);
 }
 
 /* A "pedantic" warning: issues a warning unless -pedantic-errors was
    given on the command line, in which case it issues an error.  Use
    this for diagnostics required by the relevant language standard,
@@ -522,57 +544,46 @@ warning_at (location_t location, int opt
 
    Note that these diagnostics are issued independent of the setting
    of the -pedantic command-line switch.  To get a warning enabled
    only with that switch, use either "if (pedantic) pedwarn
    (OPT_pedantic,...)" or just "pedwarn (OPT_pedantic,..)".  To get a
-   pedwarn independently of the -pedantic switch use "pedwarn (0,...)".  */
+   pedwarn independently of the -pedantic switch use "pedwarn (0,...)".
 
-void
+   Returns true if the warning was printed, false if it was inhibited.  */
+
+bool
 pedwarn (int opt, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
-  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
-                      pedantic_warning_kind ());
+  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_PEDWARN);
   diagnostic.option_index = opt;
-
-  report_diagnostic (&diagnostic);
-  va_end (ap);
-}
-
-void
-pedwarn0 (const char *gmsgid, ...)
-{
-  diagnostic_info diagnostic;
-  va_list ap;
-
-  va_start (ap, gmsgid);
-  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
-                      pedantic_warning_kind ());
-  report_diagnostic (&diagnostic);
   va_end (ap);
+  return report_diagnostic (&diagnostic);
 }
 
 /* A "permissive" error: issues an error unless -fpermissive was given
    on the command line, in which case it issues a warning.  Use this
    for things that really should be errors but we want to support
-   legacy code.  */
+   legacy code.
 
-void
+   Returns true if the warning was printed, false if it was inhibited.  */
+
+bool
 permerror (const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
 		       permissive_error_kind ());
   diagnostic.option_index = OPT_fpermissive;
-  report_diagnostic (&diagnostic);
   va_end (ap);
+  return report_diagnostic (&diagnostic);
 }
 
 
 /* A hard error: the code is definitely ill-formed, and an object file
    will not be produced.  */
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 138312)
+++ gcc/builtins.c	(working copy)
@@ -4907,26 +4907,28 @@ gimplify_va_arg_expr (tree *expr_p, gimp
      be passed through `...' due to type promotion at the call site.  */
   if ((promoted_type = lang_hooks.types.type_promotes_to (type))
 	   != type)
     {
       static bool gave_help;
+      bool warned;
 
       /* Unfortunately, this is merely undefined, rather than a constraint
 	 violation, so we cannot make this an error.  If this call is never
 	 executed, the program is still strictly conforming.  */
-      warning (0, "%qT is promoted to %qT when passed through %<...%>",
-	       type, promoted_type);
-      if (! gave_help)
+      warned = warning (0, "%qT is promoted to %qT when passed through %<...%>",
+			type, promoted_type);
+      if (!gave_help && warned)
 	{
 	  gave_help = true;
 	  inform ("(so you should pass %qT not %qT to %<va_arg%>)",
 		   promoted_type, type);
 	}
 
       /* We can, however, treat "undefined" any way we please.
 	 Call abort to encourage the user to fix the program.  */
-      inform ("if this code is reached, the program will abort");
+      if (warned)
+	inform ("if this code is reached, the program will abort");
       t = build_call_expr (implicit_built_in_decls[BUILT_IN_TRAP], 0);
       gimplify_and_add (t, pre_p);
 
       /* This is dead code, but go ahead and finish so that the
 	 mode of the result comes out right.  */
Index: gcc/diagnostic.h
===================================================================
--- gcc/diagnostic.h	(revision 138312)
+++ gcc/diagnostic.h	(working copy)
@@ -48,14 +48,10 @@ typedef struct diagnostic_info
   diagnostic_t kind;
   /* Which OPT_* directly controls this diagnostic.  */
   int option_index;
 } diagnostic_info;
 
-#define pedantic_warning_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
-#define permissive_error_kind() (flag_permissive ? DK_WARNING : DK_ERROR)
-
-
 /*  Forward declarations.  */
 typedef struct diagnostic_context diagnostic_context;
 typedef void (*diagnostic_starter_fn) (diagnostic_context *,
 				       diagnostic_info *);
 typedef diagnostic_starter_fn diagnostic_finalizer_fn;
@@ -80,11 +76,11 @@ struct diagnostic_context
   /* For each option index that can be passed to warning() et all
      (OPT_* from options.h), this array may contain a new kind that
      the diagnostic should be changed to before reporting, or
      DK_UNSPECIFIED to leave it as the reported kind, or DK_IGNORED to
      not report it at all.  N_OPTS is from <options.h>.  */
-  char classify_diagnostic[N_OPTS];
+  diagnostic_t classify_diagnostic[N_OPTS];
 
   /* True if we should print the command line option which controls
      each diagnostic, if known.  */
   bool show_option_requested;
 
@@ -197,19 +193,21 @@ extern void diagnostic_report_current_fu
 
 /* Force diagnostics controlled by OPTIDX to be kind KIND.  */
 extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *,
 						    int /* optidx */,
 						    diagnostic_t /* kind */);
-extern void diagnostic_report_diagnostic (diagnostic_context *,
+extern bool diagnostic_report_diagnostic (diagnostic_context *,
 					  diagnostic_info *);
 #ifdef ATTRIBUTE_GCC_DIAG
 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
 				 location_t, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
 extern void diagnostic_set_info_translated (diagnostic_info *, const char *,
 					    va_list *, location_t,
 					    diagnostic_t)
      ATTRIBUTE_GCC_DIAG(2,0);
+extern bool emit_diagnostic (diagnostic_t, location_t, int,
+			     const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
 #endif
 extern char *diagnostic_build_prefix (diagnostic_info *);
 
 /* Pure text formatting support functions.  */
 extern char *file_name_as_prefix (const char *);
Index: gcc/errors.c
===================================================================
--- gcc/errors.c	(revision 138312)
+++ gcc/errors.c	(working copy)
@@ -38,20 +38,21 @@ const char *progname;
 
 int have_error = 0;
 
 /* Print a warning message - output produced, but there may be problems.  */
 
-void
+bool
 warning (int opt ATTRIBUTE_UNUSED, const char *format, ...)
 {
   va_list ap;
 
   va_start (ap, format);
   fprintf (stderr, "%s: warning: ", progname);
   vfprintf (stderr, format, ap);
   va_end (ap);
   fputc('\n', stderr);
+  return true;
 }
 
 
 /* Print an error message - we keep going but the output is unusable.  */
 
Index: gcc/toplev.h
===================================================================
--- gcc/toplev.h	(revision 138312)
+++ gcc/toplev.h	(working copy)
@@ -54,22 +54,20 @@ extern void _fatal_insn (const char *, c
 #else
 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
 #endif
 extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
      ATTRIBUTE_NORETURN;
-extern void warning0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 /* Pass one of the OPT_W* from options.h as the first parameter.  */
-extern void warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
-extern void warning_at (location_t, int, const char *, ...)
+extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
+extern bool warning_at (location_t, int, const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,4);
 extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
      ATTRIBUTE_NORETURN;
-extern void pedwarn0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 /* Pass one of the OPT_W* from options.h as the first parameter.  */
-extern void pedwarn (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
-extern void permerror (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
+extern bool pedwarn (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
+extern bool permerror (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 
 extern void rest_of_decl_compilation (tree, int, int);
Index: gcc/errors.h
===================================================================
--- gcc/errors.h	(revision 138312)
+++ gcc/errors.h	(working copy)
@@ -31,11 +31,11 @@ along with GCC; see the file COPYING3.  
 
 /* The first parameter is for compatibility with the non-generator
    version of warning().  For those, you'd pass an OPT_W* value from
    options.h, but in generator programs it has no effect, so it's OK
    to just pass zero for calls from generator-only files.  */
-extern void warning (int, const char *, ...) ATTRIBUTE_PRINTF_2 ATTRIBUTE_COLD;
+extern bool warning (int, const char *, ...) ATTRIBUTE_PRINTF_2 ATTRIBUTE_COLD;
 extern void error (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_COLD;
 extern void fatal (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1 ATTRIBUTE_COLD;
 extern void internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1 ATTRIBUTE_COLD;
 extern const char *trim_filename (const char *);
 
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c	(revision 138312)
+++ gcc/cp/typeck.c	(working copy)
@@ -143,11 +143,11 @@ complete_type_or_else (tree type, tree v
   if (type == error_mark_node)
     /* We already issued an error.  */
     return NULL_TREE;
   else if (!COMPLETE_TYPE_P (type))
     {
-      cxx_incomplete_type_diagnostic (value, type, 0);
+      cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
       return NULL_TREE;
     }
   else
     return type;
 }
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c	(revision 138312)
+++ gcc/cp/init.c	(working copy)
@@ -3027,16 +3027,18 @@ build_delete (tree type, tree addr, spec
       if (!VOID_TYPE_P (type))
 	{
 	  complete_type (type);
 	  if (!COMPLETE_TYPE_P (type))
 	    {
-	      warning (0, "possible problem detected in invocation of "
-		       "delete operator:");
-	      cxx_incomplete_type_diagnostic (addr, type, 1);
-	      inform ("neither the destructor nor the class-specific "
-		      "operator delete will be called, even if they are "
-		      "declared when the class is defined.");
+	      if (warning (0, "possible problem detected in invocation of "
+			   "delete operator:"))
+		{
+		  cxx_incomplete_type_diagnostic (addr, type, DK_WARNING);
+		  inform ("neither the destructor nor the class-specific "
+			  "operator delete will be called, even if they are "
+			  "declared when the class is defined.");
+		}
 	      complete_p = false;
 	    }
 	}
       if (VOID_TYPE_P (type) || !complete_p || !MAYBE_CLASS_TYPE_P (type))
 	/* Call the builtin operator delete.  */
Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 138312)
+++ gcc/cp/call.c	(working copy)
@@ -199,12 +199,11 @@ static tree call_builtin_trap (void);
 static tree prep_operand (tree);
 static void add_candidates (tree, tree, tree, bool, tree, tree,
 			    int, struct z_candidate **);
 static conversion *merge_conversion_sequences (conversion *, conversion *);
 static bool magic_varargs_p (tree);
-typedef void (*diagnostic_fn_t) (const char *, ...) ATTRIBUTE_GCC_CXXDIAG(1,2);
-static tree build_temp (tree, tree, int, diagnostic_fn_t *);
+static tree build_temp (tree, tree, int, diagnostic_t *);
 
 /* Returns nonzero iff the destructor name specified in NAME matches BASETYPE.
    NAME can take many forms...  */
 
 bool
@@ -4443,25 +4442,25 @@ enforce_access (tree basetype_path, tree
    respectively.  If no diagnostics are generated, set *DIAGNOSTIC_FN
    to NULL.  */
 
 static tree
 build_temp (tree expr, tree type, int flags,
-	    diagnostic_fn_t *diagnostic_fn)
+	    diagnostic_t *diagnostic_kind)
 {
   int savew, savee;
 
   savew = warningcount, savee = errorcount;
   expr = build_special_member_call (NULL_TREE,
 				    complete_ctor_identifier,
 				    build_tree_list (NULL_TREE, expr),
 				    type, flags, tf_warning_or_error);
   if (warningcount > savew)
-    *diagnostic_fn = warning0;
+    *diagnostic_kind = DK_WARNING;
   else if (errorcount > savee)
-    *diagnostic_fn = error;
+    *diagnostic_kind = DK_ERROR;
   else
-    *diagnostic_fn = NULL;
+    *diagnostic_kind = 0;
   return expr;
 }
 
 /* Perform warnings about peculiar, but valid, conversions from/to NULL.
    EXPR is implicitly converted to type TOTYPE.
@@ -4503,11 +4502,11 @@ static tree
 convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 		   int inner, bool issue_conversion_warnings,
 		   bool c_cast_p, tsubst_flags_t complain)
 {
   tree totype = convs->type;
-  diagnostic_fn_t diagnostic_fn;
+  diagnostic_t diag_kind;
   int flags;
 
   if (convs->bad_p
       && convs->kind != ck_user
       && convs->kind != ck_ambig
@@ -4680,16 +4679,17 @@ convert_like_real (conversion *convs, tr
       if (convs->user_conv_p)
 	/* This conversion is being done in the context of a user-defined
 	   conversion (i.e. the second step of copy-initialization), so
 	   don't allow any more.  */
 	flags |= LOOKUP_NO_CONVERSION;
-      expr = build_temp (expr, totype, flags, &diagnostic_fn);
-      if (diagnostic_fn && fn)
+      expr = build_temp (expr, totype, flags, &diag_kind);
+      if (diag_kind && fn)
 	{
 	  if ((complain & tf_error))
-	    diagnostic_fn ("  initializing argument %P of %qD", argnum, fn);
-	  else if (diagnostic_fn == error)
+	    emit_diagnostic (diag_kind, input_location, 0, 
+			     "  initializing argument %P of %qD", argnum, fn);
+	  else if (diag_kind == DK_ERROR)
 	    return error_mark_node;
 	}
       return build_cplus_new (totype, expr);
 
     case ck_ref_bind:
@@ -6645,14 +6645,16 @@ joust (struct z_candidate *cand1, struct
       else if (warn)
 	{
 	  tree source = source_type (w->convs[0]);
 	  if (! DECL_CONSTRUCTOR_P (w->fn))
 	    source = TREE_TYPE (source);
-	  warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn);
-	  warning (OPT_Wconversion, "  for conversion from %qT to %qT",
-		   source, w->second_conv->type);
-	  inform ("  because conversion sequence for the argument is better");
+	  if (warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn)
+	      && warning (OPT_Wconversion, "  for conversion from %qT to %qT",
+			  source, w->second_conv->type)) 
+	    {
+	      inform ("  because conversion sequence for the argument is better");
+	    }
 	}
       else
 	add_warning (w, l);
     }
 
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c	(revision 138312)
+++ gcc/cp/error.c	(working copy)
@@ -2659,11 +2659,11 @@ cp_cpp_error (cpp_reader *pfile ATTRIBUT
     case CPP_DL_WARNING:
     case CPP_DL_WARNING_SYSHDR:
       dlevel = DK_WARNING;
       break;
     case CPP_DL_PEDWARN:
-      dlevel = pedantic_warning_kind ();
+      dlevel = DK_PEDWARN;
       break;
     case CPP_DL_ERROR:
       dlevel = DK_ERROR;
       break;
     case CPP_DL_ICE:
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 138312)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -29,12 +29,32 @@ along with GCC; see the file COPYING3.  
 #include "splay-tree.h"
 #include "vec.h"
 #include "varray.h"
 #include "c-common.h"
 #include "name-lookup.h"
-struct diagnostic_context;
-struct diagnostic_info;
+
+/* In order for the format checking to accept the C++ front end
+   diagnostic framework extensions, you must include this file before
+   toplev.h, not after.  We override the definition of GCC_DIAG_STYLE
+   in c-common.h.  */
+#undef GCC_DIAG_STYLE
+#define GCC_DIAG_STYLE __gcc_cxxdiag__
+#if GCC_VERSION >= 4001
+#define ATTRIBUTE_GCC_CXXDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
+#else
+#define ATTRIBUTE_GCC_CXXDIAG(m, n) ATTRIBUTE_NONNULL(m)
+#endif
+extern void cp_cpp_error			(cpp_reader *, int,
+						 const char *, va_list *)
+     ATTRIBUTE_GCC_CXXDIAG(3,0);
+#ifdef GCC_TOPLEV_H
+#error \
+"In order for the format checking to accept the C++ front end diagnostic\n"
+"framework extensions, you must include this file before toplev.h, not after."
+#endif
+#include "toplev.h"
+#include "diagnostic.h"
 
 /* Usage of TREE_LANG_FLAG_?:
    0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
       NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
       DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
@@ -4884,15 +4904,15 @@ extern int lvalue_or_else			(const_tree,
                                                  tsubst_flags_t);
 extern int lvalue_p				(const_tree);
 
 /* in typeck2.c */
 extern void require_complete_eh_spec_types	(tree, tree);
-extern void cxx_incomplete_type_diagnostic	(const_tree, const_tree, int);
+extern void cxx_incomplete_type_diagnostic	(const_tree, const_tree, diagnostic_t);
 #undef cxx_incomplete_type_error
 extern void cxx_incomplete_type_error		(const_tree, const_tree);
 #define cxx_incomplete_type_error(V,T) \
-  (cxx_incomplete_type_diagnostic ((V), (T), 0))
+  (cxx_incomplete_type_diagnostic ((V), (T), DK_ERROR))
 extern tree error_not_base_type			(tree, tree);
 extern tree binfo_or_else			(tree, tree);
 extern void readonly_error			(tree, const char *);
 extern void complete_type_check_abstract	(tree);
 extern int abstract_virtuals_error		(tree, tree);
@@ -4942,21 +4962,6 @@ extern int cp_gimplify_expr			(tree *, g
 						 gimple_seq *);
 extern void cp_genericize			(tree);
 
 /* -- end of C++ */
 
-/* In order for the format checking to accept the C++ front end
-   diagnostic framework extensions, you must include this file before
-   toplev.h, not after.  We override the definition of GCC_DIAG_STYLE
-   in c-common.h.  */
-#undef GCC_DIAG_STYLE
-#define GCC_DIAG_STYLE __gcc_cxxdiag__
-#if GCC_VERSION >= 4001
-#define ATTRIBUTE_GCC_CXXDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
-#else
-#define ATTRIBUTE_GCC_CXXDIAG(m, n) ATTRIBUTE_NONNULL(m)
-#endif
-extern void cp_cpp_error			(cpp_reader *, int,
-						 const char *, va_list *)
-     ATTRIBUTE_GCC_CXXDIAG(3,0);
-
 #endif /* ! GCC_CP_TREE_H */
Index: gcc/cp/friend.c
===================================================================
--- gcc/cp/friend.c	(revision 138312)
+++ gcc/cp/friend.c	(working copy)
@@ -566,13 +566,15 @@ do_friend (tree ctype, tree declarator, 
 	    }
 
 	  if (warn)
 	    {
 	      static int explained;
-	      warning (OPT_Wnon_template_friend, "friend declaration "
-		       "%q#D declares a non-template function", decl);
-	      if (! explained)
+	      bool warned;
+
+	      warned = warning (OPT_Wnon_template_friend, "friend declaration "
+				"%q#D declares a non-template function", decl);
+	      if (! explained && warned)
 		{
 		  inform ("(if this is not what you intended, make sure "
 			  "the function template has already been declared "
 			  "and add <> after the function name here) ");
 		  explained = 1;
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c	(revision 138312)
+++ gcc/cp/typeck2.c	(working copy)
@@ -330,36 +330,33 @@ abstract_virtuals_error (tree decl, tree
   return 1;
 }
 
 /* Print an error message for invalid use of an incomplete type.
    VALUE is the expression that was used (or 0 if that isn't known)
-   and TYPE is the type that was invalid.  DIAG_TYPE indicates the
-   type of diagnostic:  0 for an error, 1 for a warning, 2 for a
-   pedwarn.  */
+   and TYPE is the type that was invalid.  DIAG_KIND indicates the
+   type of diagnostic (see diagnostic.def).  */
 
 void
-cxx_incomplete_type_diagnostic (const_tree value, const_tree type, int diag_type)
+cxx_incomplete_type_diagnostic (const_tree value, const_tree type, 
+				diagnostic_t diag_kind)
 {
   int decl = 0;
-  void (*p_msg) (const char *, ...) ATTRIBUTE_GCC_CXXDIAG(1,2);
 
-  if (diag_type == 1)
-    p_msg = warning0;
-  else if (diag_type == 2)
-    p_msg = pedwarn0;
-  else
-    p_msg = error;
+  gcc_assert (diag_kind == DK_WARNING 
+	      || diag_kind == DK_PEDWARN 
+	      || diag_kind == DK_ERROR);
 
   /* Avoid duplicate error message.  */
   if (TREE_CODE (type) == ERROR_MARK)
     return;
 
   if (value != 0 && (TREE_CODE (value) == VAR_DECL
 		     || TREE_CODE (value) == PARM_DECL
 		     || TREE_CODE (value) == FIELD_DECL))
     {
-      p_msg ("%q+D has incomplete type", value);
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "%q+D has incomplete type", value);
       decl = 1;
     }
  retry:
   /* We must print an error message.  Be clever about what it says.  */
 
@@ -367,58 +364,70 @@ cxx_incomplete_type_diagnostic (const_tr
     {
     case RECORD_TYPE:
     case UNION_TYPE:
     case ENUMERAL_TYPE:
       if (!decl)
-	p_msg ("invalid use of incomplete type %q#T", type);
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "invalid use of incomplete type %q#T", type);
       if (!TYPE_TEMPLATE_INFO (type))
-	p_msg ("forward declaration of %q+#T", type);
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "forward declaration of %q+#T", type);
       else
-	p_msg ("declaration of %q+#T", type);
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "declaration of %q+#T", type);
       break;
 
     case VOID_TYPE:
-      p_msg ("invalid use of %qT", type);
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of %qT", type);
       break;
 
     case ARRAY_TYPE:
       if (TYPE_DOMAIN (type))
 	{
 	  type = TREE_TYPE (type);
 	  goto retry;
 	}
-      p_msg ("invalid use of array with unspecified bounds");
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of array with unspecified bounds");
       break;
 
     case OFFSET_TYPE:
     bad_member:
-      p_msg ("invalid use of member (did you forget the %<&%> ?)");
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of member (did you forget the %<&%> ?)");
       break;
 
     case TEMPLATE_TYPE_PARM:
-      p_msg ("invalid use of template type parameter %qT", type);
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of template type parameter %qT", type);
       break;
 
     case BOUND_TEMPLATE_TEMPLATE_PARM:
-      p_msg ("invalid use of template template parameter %qT",
-            TYPE_NAME (type));
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of template template parameter %qT",
+		       TYPE_NAME (type));
       break;
 
     case TYPENAME_TYPE:
-      p_msg ("invalid use of dependent type %qT", type);
+      emit_diagnostic (diag_kind, input_location, 0,
+		       "invalid use of dependent type %qT", type);
       break;
 
     case UNKNOWN_TYPE:
       if (value && TREE_CODE (value) == COMPONENT_REF)
 	goto bad_member;
       else if (value && TREE_CODE (value) == ADDR_EXPR)
-	p_msg ("address of overloaded function with no contextual "
-	       "type information");
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "address of overloaded function with no contextual "
+			 "type information");
       else if (value && TREE_CODE (value) == OVERLOAD)
-	p_msg ("overloaded function with no contextual type information");
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "overloaded function with no contextual type information");
       else
-	p_msg ("insufficient contextual information to determine type");
+	emit_diagnostic (diag_kind, input_location, 0,
+			 "insufficient contextual information to determine type");
       break;
 
     default:
       gcc_unreachable ();
     }
@@ -428,11 +437,11 @@ cxx_incomplete_type_diagnostic (const_tr
    required by ../tree.c.  */
 #undef cxx_incomplete_type_error
 void
 cxx_incomplete_type_error (const_tree value, const_tree type)
 {
-  cxx_incomplete_type_diagnostic (value, type, 0);
+  cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
 }
 
 
 /* The recursive part of split_nonconstant_init.  DEST is an lvalue
    expression to which INIT should be assigned.  INIT is a CONSTRUCTOR.  */
@@ -1472,11 +1481,11 @@ tree
 add_exception_specifier (tree list, tree spec, int complain)
 {
   bool ok;
   tree core = spec;
   bool is_ptr;
-  int diag_type = -1; /* none */
+  diagnostic_t diag_type = DK_UNSPECIFIED; /* none */
 
   if (spec == error_mark_node)
     return list;
 
   gcc_assert (spec && (!list || TREE_VALUE (list)));
@@ -1501,11 +1510,11 @@ add_exception_specifier (tree list, tree
       /* 15.4/1 says that types in an exception specifier must be complete,
 	 but it seems more reasonable to only require this on definitions
 	 and calls.  So just give a pedwarn at this point; we will give an
 	 error later if we hit one of those two cases.  */
       if (!COMPLETE_TYPE_P (complete_type (core)))
-	diag_type = 2; /* pedwarn */
+	diag_type = DK_PEDWARN; /* pedwarn */
     }
 
   if (ok)
     {
       tree probe;
@@ -1515,13 +1524,13 @@ add_exception_specifier (tree list, tree
 	  break;
       if (!probe)
 	list = tree_cons (NULL_TREE, spec, list);
     }
   else
-    diag_type = 0; /* error */
+    diag_type = DK_ERROR; /* error */
 
-  if (diag_type >= 0 && complain)
+  if (diag_type != DK_UNSPECIFIED && complain)
     cxx_incomplete_type_diagnostic (NULL_TREE, core, diag_type);
 
   return list;
 }
 
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 138312)
+++ gcc/cp/parser.c	(working copy)
@@ -9978,19 +9978,18 @@ cp_parser_template_id (cp_parser *parser
 	  pop_deferring_access_checks ();
 	  return error_mark_node;
 	}
       /* Otherwise, emit an error about the invalid digraph, but continue
 	 parsing because we got our argument list.  */
-      permerror ("%H%<<::%> cannot begin a template-argument list",
-		 &next_token->location);
-      inform ("%H%<<:%> is an alternate spelling for %<[%>. Insert whitespace "
+      if (permerror ("%H%<<::%> cannot begin a template-argument list",
+		     &next_token->location))
+	{
+	  static bool hint = false;
+	  inform ("%H%<<:%> is an alternate spelling for %<[%>. Insert whitespace "
 	      "between %<<%> and %<::%>",
 	      &next_token->location);
-      if (!flag_permissive)
-	{
-	  static bool hint;
-	  if (!hint)
+	  if (!hint && !flag_permissive)
 	    {
 	      inform ("%H(if you use %<-fpermissive%> G++ will accept your code)",
                       &next_token->location);
 	      hint = true;
 	    }
Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c	(revision 138312)
+++ gcc/c-decl.c	(working copy)
@@ -1113,20 +1113,20 @@ validate_proto_after_old_defn (tree newd
 
 /* Subroutine of diagnose_mismatched_decls.  Report the location of DECL,
    first in a pair of mismatched declarations, using the diagnostic
    function DIAG.  */
 static void
-locate_old_decl (tree decl, void (*diag)(const char *, ...) ATTRIBUTE_GCC_CDIAG(1,2))
+locate_old_decl (tree decl)
 {
   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
     ;
   else if (DECL_INITIAL (decl))
-    diag (G_("previous definition of %q+D was here"), decl);
+    inform ("previous definition of %q+D was here", decl);
   else if (C_DECL_IMPLICIT (decl))
-    diag (G_("previous implicit declaration of %q+D was here"), decl);
+    inform ("previous implicit declaration of %q+D was here", decl);
   else
-    diag (G_("previous declaration of %q+D was here"), decl);
+    inform ("previous declaration of %q+D was here", decl);
 }
 
 /* Subroutine of duplicate_decls.  Compare NEWDECL to OLDDECL.
    Returns true if the caller should proceed to merge the two, false
    if OLDDECL should simply be discarded.  As a side effect, issues
@@ -1163,11 +1163,11 @@ diagnose_mismatched_decls (tree newdecl,
       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
 	    && DECL_BUILT_IN (olddecl)
 	    && !C_DECL_DECLARED_BUILTIN (olddecl)))
 	{
 	  error ("%q+D redeclared as different kind of symbol", newdecl);
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	}
       else if (TREE_PUBLIC (newdecl))
 	warning (0, "built-in function %q+D declared as non-function",
 		 newdecl);
       else
@@ -1179,11 +1179,11 @@ diagnose_mismatched_decls (tree newdecl,
   /* Enumerators have no linkage, so may only be declared once in a
      given scope.  */
   if (TREE_CODE (olddecl) == CONST_DECL)
     {
       error ("redeclaration of enumerator %q+D", newdecl);
-      locate_old_decl (olddecl, error);
+      locate_old_decl (olddecl);
       return false;
     }
 
   if (!comptypes (oldtype, newtype))
     {
@@ -1223,36 +1223,34 @@ diagnose_mismatched_decls (tree newdecl,
       else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl)
 	       && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
 	       && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
 	       && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
 	{
-	  pedwarn (0, "conflicting types for %q+D", newdecl);
+	  pedwarned = pedwarn (0, "conflicting types for %q+D", newdecl);
 	  /* Make sure we keep void as the return type.  */
 	  TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
 	  C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
-	  pedwarned = true;
 	}
       /* Permit void foo (...) to match an earlier call to foo (...) with
 	 no declared type (thus, implicitly int).  */
       else if (TREE_CODE (newdecl) == FUNCTION_DECL
 	       && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
 	       && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
 	       && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
 	{
-	  pedwarn (0, "conflicting types for %q+D", newdecl);
+	  pedwarned = pedwarn (0, "conflicting types for %q+D", newdecl);
 	  /* Make sure we keep void as the return type.  */
 	  TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
-	  pedwarned = true;
 	}
       else
 	{
 	  if (TYPE_QUALS (newtype) != TYPE_QUALS (oldtype))
 	    error ("conflicting type qualifiers for %q+D", newdecl);
 	  else
 	    error ("conflicting types for %q+D", newdecl);
 	  diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype);
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	  return false;
 	}
     }
 
   /* Redeclaration of a type is a constraint violation (6.7.2.3p1),
@@ -1265,11 +1263,11 @@ diagnose_mismatched_decls (tree newdecl,
 	  || TREE_NO_WARNING (newdecl)
 	  || TREE_NO_WARNING (olddecl))
 	return true;  /* Allow OLDDECL to continue in use.  */
 
       error ("redefinition of typedef %q+D", newdecl);
-      locate_old_decl (olddecl, error);
+      locate_old_decl (olddecl);
       return false;
     }
 
   /* Function declarations can either be 'static' or 'extern' (no
      qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore
@@ -1316,11 +1314,11 @@ diagnose_mismatched_decls (tree newdecl,
 						 DECL_ATTRIBUTES (newdecl))))
 		  )
 		  && same_translation_unit_p (newdecl, olddecl))
 		{
 		  error ("redefinition of %q+D", newdecl);
-		  locate_old_decl (olddecl, error);
+		  locate_old_decl (olddecl);
 		  return false;
 		}
 	    }
 	}
       /* If we have a prototype after an old-style function definition,
@@ -1328,11 +1326,11 @@ diagnose_mismatched_decls (tree newdecl,
       else if (DECL_INITIAL (olddecl)
 	       && !TYPE_ARG_TYPES (oldtype) && TYPE_ARG_TYPES (newtype)
 	       && TYPE_ACTUAL_ARG_TYPES (oldtype)
 	       && !validate_proto_after_old_defn (newdecl, newtype, oldtype))
 	{
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	  return false;
 	}
       /* A non-static declaration (even an "extern") followed by a
 	 static declaration is undefined behavior per C99 6.2.2p3-5,7.
 	 The same is true for a static forward declaration at block
@@ -1352,28 +1350,28 @@ diagnose_mismatched_decls (tree newdecl,
 	  if (!DECL_IS_BUILTIN (olddecl)
 	      && !DECL_EXTERN_INLINE (olddecl))
 	    {
 	      error ("static declaration of %q+D follows "
 		     "non-static declaration", newdecl);
-	      locate_old_decl (olddecl, error);
+	      locate_old_decl (olddecl);
 	    }
 	  return false;
 	}
       else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl))
 	{
 	  if (DECL_CONTEXT (olddecl))
 	    {
 	      error ("non-static declaration of %q+D follows "
 		     "static declaration", newdecl);
-	      locate_old_decl (olddecl, error);
+	      locate_old_decl (olddecl);
 	      return false;
 	    }
 	  else if (warn_traditional)
 	    {
-	      warning (OPT_Wtraditional, "non-static declaration of %q+D "
-		       "follows static declaration", newdecl);
-	      warned = true;
+	      warned |= warning (OPT_Wtraditional, 
+				 "non-static declaration of %q+D "
+				 "follows static declaration", newdecl);
 	    }
 	}
 
       /* Make sure gnu_inline attribute is either not present, or
 	 present on all inline decls.  */
@@ -1410,19 +1408,19 @@ diagnose_mismatched_decls (tree newdecl,
 		   "non-thread-local declaration", newdecl);
 	  else
 	    error ("non-thread-local declaration of %q+D follows "
 		   "thread-local declaration", newdecl);
 
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	  return false;
 	}
 
       /* Multiple initialized definitions are not allowed (6.9p3,5).  */
       if (DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl))
 	{
 	  error ("redefinition of %q+D", newdecl);
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	  return false;
 	}
 
       /* Objects declared at file scope: if the first declaration had
 	 external linkage (even if it was an external reference) the
@@ -1439,18 +1437,18 @@ diagnose_mismatched_decls (tree newdecl,
 	    {
 	      if (!DECL_FILE_SCOPE_P (olddecl))
 		{
 		  error ("extern declaration of %q+D follows "
 			 "declaration with no linkage", newdecl);
-		  locate_old_decl (olddecl, error);
+		  locate_old_decl (olddecl);
 		  return false;
 		}
 	      else if (warn_traditional)
 		{
-		  warning (OPT_Wtraditional, "non-static declaration of %q+D "
-			   "follows static declaration", newdecl);
-		  warned = true;
+		  warned |= warning (OPT_Wtraditional, 
+				     "non-static declaration of %q+D "
+				     "follows static declaration", newdecl);
 		}
 	    }
 	  else
 	    {
 	      if (TREE_PUBLIC (newdecl))
@@ -1458,11 +1456,11 @@ diagnose_mismatched_decls (tree newdecl,
 		       "static declaration", newdecl);
 	      else
 		error ("static declaration of %q+D follows "
 		       "non-static declaration", newdecl);
 
-	      locate_old_decl (olddecl, error);
+	      locate_old_decl (olddecl);
 	      return false;
 	    }
 	}
       /* Two objects with the same name declared at the same block
 	 scope must both be external references (6.7p3).  */
@@ -1475,16 +1473,16 @@ diagnose_mismatched_decls (tree newdecl,
 	    }
 	  else if (DECL_EXTERNAL (olddecl))
 	    {
 	      error ("declaration of %q+D with no linkage follows "
 		     "extern declaration", newdecl);
-	      locate_old_decl (olddecl, error);
+	      locate_old_decl (olddecl);
 	    }
 	  else
 	    {
 	      error ("redeclaration of %q+D with no linkage", newdecl);
-	      locate_old_decl (olddecl, error);
+	      locate_old_decl (olddecl);
 	    }
 
 	  return false;
 	}
     }
@@ -1493,31 +1491,30 @@ diagnose_mismatched_decls (tree newdecl,
   /* All decls must agree on a visibility.  */
   if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
       && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
     {
-      warning (0, "redeclaration of %q+D with different visibility "
-	       "(old visibility preserved)", newdecl);
-      warned = true;
+      warned |= warning (0, "redeclaration of %q+D with different visibility "
+			 "(old visibility preserved)", newdecl);
     }
 
   if (TREE_CODE (newdecl) == FUNCTION_DECL)
     {
       /* Diagnose inline __attribute__ ((noinline)) which is silly.  */
       if (DECL_DECLARED_INLINE_P (newdecl)
 	  && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
 	{
-	  warning (OPT_Wattributes, "inline declaration of %qD follows "
-		   "declaration with attribute noinline", newdecl);
-	  warned = true;
+	  warned |= warning (OPT_Wattributes, 
+			     "inline declaration of %qD follows "
+			     "declaration with attribute noinline", newdecl);
 	}
       else if (DECL_DECLARED_INLINE_P (olddecl)
 	       && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
 	{
-	  warning (OPT_Wattributes, "declaration of %q+D with attribute "
-		   "noinline follows inline declaration ", newdecl);
-	  warned = true;
+	  warned |= warning (OPT_Wattributes, 
+			     "declaration of %q+D with attribute "
+			     "noinline follows inline declaration ", newdecl);
 	}
     }
   else /* PARM_DECL, VAR_DECL */
     {
       /* Redeclaration of a parameter is a constraint violation (this is
@@ -1531,11 +1528,11 @@ diagnose_mismatched_decls (tree newdecl,
 
       if (TREE_CODE (newdecl) == PARM_DECL
 	  && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
 	{
 	  error ("redefinition of parameter %q+D", newdecl);
-	  locate_old_decl (olddecl, error);
+	  locate_old_decl (olddecl);
 	  return false;
 	}
     }
 
   /* Optional warning for completely redundant decls.  */
@@ -1557,18 +1554,17 @@ diagnose_mismatched_decls (tree newdecl,
 	   && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
       /* Don't warn about a variable definition following a declaration.  */
       && !(TREE_CODE (newdecl) == VAR_DECL
 	   && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
     {
-      warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
-	       newdecl);
-      warned = true;
+      warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
+			newdecl);
     }
 
-  /* Report location of previous decl/defn in a consistent manner.  */
+  /* Report location of previous decl/defn.  */
   if (warned || pedwarned)
-    locate_old_decl (olddecl, pedwarned ? pedwarn0 : warning0);
+    locate_old_decl (olddecl);
 
 #undef DECL_EXTERN_INLINE
 
   return retval;
 }
@@ -2328,18 +2324,20 @@ pushdecl_top_level (tree x)
 static void
 implicit_decl_warning (tree id, tree olddecl)
 {
   if (warn_implicit_function_declaration)
     {
+      bool warned;
+
       if (flag_isoc99)
-	pedwarn (OPT_Wimplicit_function_declaration, 
-		 G_("implicit declaration of function %qE"), id);
+	warned = pedwarn (OPT_Wimplicit_function_declaration, 
+			  G_("implicit declaration of function %qE"), id);
       else 
-	warning (OPT_Wimplicit_function_declaration, 
-		 G_("implicit declaration of function %qE"), id);
-      if (olddecl)
-	locate_old_decl (olddecl, inform);
+	warned = warning (OPT_Wimplicit_function_declaration, 
+			  G_("implicit declaration of function %qE"), id);
+      if (olddecl && warned)
+	locate_old_decl (olddecl);
     }
 }
 
 /* Generate an implicit declaration for identifier FUNCTIONID as a
    function of type int ().  */
@@ -2406,11 +2404,11 @@ implicitly_declare (tree functionid)
 	    {
 	      if (!comptypes (newtype, TREE_TYPE (decl)))
 		{
 		  error ("incompatible implicit declaration of function %qD",
 			 decl);
-		  locate_old_decl (decl, error);
+		  locate_old_decl (decl);
 		}
 	    }
 	  b->type = TREE_TYPE (decl);
 	  TREE_TYPE (decl) = newtype;
 	  bind (functionid, decl, current_scope,
@@ -2548,11 +2546,11 @@ declare_label (tree name)
   /* Check to make sure that the label hasn't already been declared
      at this scope */
   if (b && B_IN_CURRENT_SCOPE (b))
     {
       error ("duplicate label declaration %qE", name);
-      locate_old_decl (b->decl, error);
+      locate_old_decl (b->decl);
 
       /* Just use the previous declaration.  */
       return b->decl;
     }
 
@@ -2584,11 +2582,11 @@ define_label (location_t location, tree 
 	   && DECL_INITIAL (label) != 0)
 	  || (DECL_CONTEXT (label) != current_function_decl
 	      && C_DECLARED_LABEL_FLAG (label))))
     {
       error ("%Hduplicate label %qD", &location, label);
-      locate_old_decl (label, error);
+      locate_old_decl (label);
       return 0;
     }
   else if (label && DECL_CONTEXT (label) == current_function_decl)
     {
       /* The label has been used or declared already in this function,
Index: gcc/fortran/f95-lang.c
===================================================================
--- gcc/fortran/f95-lang.c	(revision 138312)
+++ gcc/fortran/f95-lang.c	(working copy)
@@ -602,12 +602,12 @@ gfc_mark_addressable (tree exp)
 	      {
 		error ("global register variable %qs used in nested function",
 		       IDENTIFIER_POINTER (DECL_NAME (x)));
 		return false;
 	      }
-	    pedwarn0 ("register variable %qs used in nested function",
-		      IDENTIFIER_POINTER (DECL_NAME (x)));
+	    pedwarn (0, "register variable %qs used in nested function",
+		     IDENTIFIER_POINTER (DECL_NAME (x)));
 	  }
 	else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
 	  {
 	    if (TREE_PUBLIC (x))
 	      {
@@ -627,11 +627,11 @@ gfc_mark_addressable (tree exp)
 		error ("cannot put object with volatile field into register");
 		return false;
 	      }
 #endif
 
-	    pedwarn0 ("address of register variable %qs requested",
+	    pedwarn (0, "address of register variable %qs requested",
 		     IDENTIFIER_POINTER (DECL_NAME (x)));
 	  }
 
 	/* drops in */
       case FUNCTION_DECL:
Index: gcc/c-errors.c
===================================================================
--- gcc/c-errors.c	(revision 138312)
+++ gcc/c-errors.c	(working copy)
@@ -36,11 +36,11 @@ pedwarn_c99 (int opt, const char *gmsgid
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
-		       flag_isoc99 ? pedantic_warning_kind () : DK_WARNING);
+		       flag_isoc99 ? DK_PEDWARN : DK_WARNING);
   diagnostic.option_index = opt;
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
@@ -55,10 +55,10 @@ pedwarn_c90 (int opt, const char *gmsgid
   diagnostic_info diagnostic;
   va_list ap;
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
-		       flag_isoc99 ? DK_WARNING : pedantic_warning_kind ());
+		       flag_isoc99 ? DK_WARNING : DK_PEDWARN);
   diagnostic.option_index = opt;
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c	(revision 138312)
+++ gcc/c-typeck.c	(working copy)
@@ -2406,15 +2406,14 @@ build_function_call (tree function, tree
 				       NULL_TREE);
 
       /* This situation leads to run-time undefined behavior.  We can't,
 	 therefore, simply error unless we can prove that all possible
 	 executions of the program must execute the code.  */
-      warning (0, "function called through a non-compatible type");
-
-      /* We can, however, treat "undefined" any way we please.
-	 Call abort to encourage the user to fix the program.  */
-      inform ("if this code is reached, the program will abort");
+      if (warning (0, "function called through a non-compatible type"))
+	/* We can, however, treat "undefined" any way we please.
+	   Call abort to encourage the user to fix the program.  */
+	inform ("if this code is reached, the program will abort");
 
       if (VOID_TYPE_P (return_type))
 	return trap;
       else
 	{
Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c	(revision 138312)
+++ gcc/tree-ssa.c	(working copy)
@@ -1406,19 +1406,21 @@ warn_uninit (tree t, const char *gmsgid,
     return;
 
   location = (context != NULL && gimple_has_location (context))
 	     ? gimple_location (context)
 	     : DECL_SOURCE_LOCATION (var);
-  warning_at (location, OPT_Wuninitialized, gmsgid, var);
   xloc = expand_location (location);
   floc = expand_location (DECL_SOURCE_LOCATION (cfun->decl));
-  if (xloc.file != floc.file
-      || xloc.line < floc.line
-      || xloc.line > LOCATION_LINE (cfun->function_end_locus))
-    inform ("%J%qD was declared here", var, var);
+  if (warning_at (location, OPT_Wuninitialized, gmsgid, var))
+    {
+      TREE_NO_WARNING (var) = 1;
 
-  TREE_NO_WARNING (var) = 1;
+      if (xloc.file != floc.file
+	  || xloc.line < floc.line
+	  || xloc.line > LOCATION_LINE (cfun->function_end_locus))
+	inform ("%J%qD was declared here", var, var);
+    }
 }
 
 struct walk_data {
   gimple stmt;
   bool always_executed;
Index: gcc/testsuite/gcc.target/powerpc/altivec-macros.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/altivec-macros.c	(revision 138311)
+++ gcc/testsuite/gcc.target/powerpc/altivec-macros.c	(working copy)
@@ -53,11 +53,11 @@ _Pragma ("__vector")
 /* { dg-warning "redefined" "__bool redefined"    { target *-*-* } 46 } */
 /* { dg-warning "redefined" "vector redefined"    { target *-*-* } 47 } */
 /* { dg-warning "redefined" "pixel redefined"     { target *-*-* } 48 } */
 /* { dg-warning "redefined" "bool redefined"      { target *-*-* } 49 } */
 
-/* { dg-warning "previous"  "prev __vector defn"  { target *-*-* } 24 } */
-/* { dg-warning "previous"  "prev __pixel defn"   { target *-*-* } 27 } */
-/* { dg-warning "previous"  "prev __bool defn"    { target *-*-* } 30 } */
-/* { dg-warning "previous"  "prev vector defn"    { target *-*-* } 33 } */
-/* { dg-warning "previous"  "prev pixel defn"     { target *-*-* } 36 } */
-/* { dg-warning "previous"  "prev bool defn"      { target *-*-* } 39 } */
+/* { dg-message "note: previous"  "prev __vector defn"  { target *-*-* } 24 } */
+/* { dg-message "note: previous"  "prev __pixel defn"   { target *-*-* } 27 } */
+/* { dg-message "note: previous"  "prev __bool defn"    { target *-*-* } 30 } */
+/* { dg-message "note: previous"  "prev vector defn"    { target *-*-* } 33 } */
+/* { dg-message "note: previous"  "prev pixel defn"     { target *-*-* } 36 } */
+/* { dg-message "note: previous"  "prev bool defn"      { target *-*-* } 39 } */
Index: gcc/testsuite/gcc.target/i386/regparm.c
===================================================================
--- gcc/testsuite/gcc.target/i386/regparm.c	(revision 138311)
+++ gcc/testsuite/gcc.target/i386/regparm.c	(working copy)
@@ -1,10 +1,10 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-options "-W -Wall" } */
 
 /* Verify that GCC correctly detects non-matching regparm attributes.  */
-int __attribute__((regparm(3))) f (void);  /* { dg-error "previous" } */
+int __attribute__((regparm(3))) f (void);  /* { dg-message "note: previous" } */
 
 int __attribute__((regparm(2))) f (void) { /* { dg-error "conflicting" } */
   return 0;
 }
Index: gcc/testsuite/gcc.dg/funcdef-var-1.c
===================================================================
--- gcc/testsuite/gcc.dg/funcdef-var-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/funcdef-var-1.c	(working copy)
@@ -3,8 +3,8 @@
    <aldot@gcc.gnu.org>.  */
 /* { dg-do compile } */
 /* { dg-options "-Wmissing-prototypes" } */
 
 extern __typeof(foo) foo __asm__(""); /* { dg-error "undeclared" } */
-/* { dg-error "previous declaration" "previous declaration" { target *-*-* } 7 } */
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } 7 } */
 void *foo (void) {} /* { dg-error "redeclared as different kind of symbol" } */
 /* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } 9 } */
Index: gcc/testsuite/gcc.dg/parm-mismatch-1.c
===================================================================
--- gcc/testsuite/gcc.dg/parm-mismatch-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/parm-mismatch-1.c	(working copy)
@@ -2,17 +2,17 @@
    ().  */
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
-void f0(); /* { dg-error "previous declaration of 'f0' was here" } */
+void f0(); /* { dg-message "note: previous declaration of 'f0' was here" } */
 void f0(int, ...); /* { dg-error "conflicting types for 'f0'" } */
 /* { dg-message "note: a parameter list with an ellipsis can't match an empty parameter name list declaration" "note" { target *-*-* } 8 } */
-void f1(int, ...); /* { dg-error "previous declaration of 'f1' was here" } */
+void f1(int, ...); /* { dg-message "note: previous declaration of 'f1' was here" } */
 void f1(); /* { dg-error "conflicting types for 'f1'" } */
 /* { dg-message "note: a parameter list with an ellipsis can't match an empty parameter name list declaration" "note" { target *-*-* } 11 } */
-void f2(); /* { dg-error "previous declaration of 'f2' was here" } */
+void f2(); /* { dg-message "note: previous declaration of 'f2' was here" } */
 void f2(char); /* { dg-error "conflicting types for 'f2'" } */
 /* { dg-message "note: an argument type that has a default promotion can't match an empty parameter name list declaration" "note" { target *-*-* } 14 } */
-void f3(char); /* { dg-error "previous declaration of 'f3' was here" } */
+void f3(char); /* { dg-message "note: previous declaration of 'f3' was here" } */
 void f3(); /* { dg-error "conflicting types for 'f3'" } */
 /* { dg-message "note: an argument type that has a default promotion can't match an empty parameter name list declaration" "note" { target *-*-* } 17 } */
Index: gcc/testsuite/gcc.dg/attr-noinline.c
===================================================================
--- gcc/testsuite/gcc.dg/attr-noinline.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/attr-noinline.c	(working copy)
@@ -11,35 +11,35 @@ static void function_declaration_both_af
 
 static inline void __attribute__((__noinline__)) function_declaration_both_after(void); /* { dg-warning "(inline function \[^\n\]* given attribute noinline|declared inline after its definition)" "" } */
 
 static void function_declaration_both_after(void) {}
 
-static void function_declaration_noinline_before(void) __attribute__((__noinline__)); /* { dg-warning "previous declaration" "" } */
+static void function_declaration_noinline_before(void) __attribute__((__noinline__)); /* { dg-message "note: previous declaration" "" } */
 
 static inline void function_declaration_noinline_before(void) {} /* { dg-warning "follows declaration with attribute noinline" "" } */
 
-static inline void function_declaration_noinline_after(void) {} /* { dg-warning "previous definition" "" } */
+static inline void function_declaration_noinline_after(void) {} /* { dg-message "note: previous definition" "" } */
 
 static void function_declaration_noinline_after(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" "" } */
 
-static inline void function_declaration_inline_before(void); /* { dg-warning "previous declaration" "" } */
+static inline void function_declaration_inline_before(void); /* { dg-message "note: previous declaration" "" } */
 
 static void __attribute__((__noinline__)) function_declaration_inline_before(void) {} /* { dg-warning "follows inline declaration" "" } */
 
-static inline void function_declaration_inline_noinline_before(void); /* { dg-warning "previous declaration" "" } */
+static inline void function_declaration_inline_noinline_before(void); /* { dg-message "note: previous declaration" "" } */
 
 static void function_declaration_inline_noinline_before(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" "" } */
 
 static void function_declaration_inline_noinline_before(void) {}
 
 static inline void function_declaration_inline_noinline_after(void);
 
-static void function_declaration_inline_noinline_after(void) {} /* { dg-warning "previous definition" "" } */
+static void function_declaration_inline_noinline_after(void) {} /* { dg-message "note: previous definition" "" } */
 
 static void function_declaration_inline_noinline_after(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" "" } */
 
-static void function_declaration_noinline_inline_before(void) __attribute__((__noinline__)); /* { dg-warning "previous declaration" "" } */
+static void function_declaration_noinline_inline_before(void) __attribute__((__noinline__)); /* { dg-message "note: previous declaration" "" } */
 
 static inline void function_declaration_noinline_inline_before(void); /* { dg-warning "follows declaration with attribute noinline" "" } */
 
 static void function_declaration_noinline_inline_before(void) {}
 
Index: gcc/testsuite/gcc.dg/wtr-static-1.c
===================================================================
--- gcc/testsuite/gcc.dg/wtr-static-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/wtr-static-1.c	(working copy)
@@ -2,11 +2,11 @@
    Note, gcc should omit these warnings in system header files.
    By Kaveh R. Ghazi <ghazi@caip.rutgers.edu>  8/22/2000.  */
 /* { dg-do compile } */
 /* { dg-options "-Wtraditional" } */
 
-static void testfunc1(void); /* { dg-warning "previous declaration" } */
+static void testfunc1(void); /* { dg-message "note: previous declaration" } */
 void testfunc1() {} /* { dg-warning "non-static.*follows static" "non-static follows static" } */
 
 # 11 "sys-header.h" 3
 /* We are in system headers now, no -Wtraditional warnings should issue.  */
 
Index: gcc/testsuite/gcc.dg/redecl-11.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-11.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-11.c	(working copy)
@@ -3,7 +3,7 @@
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
 int f(int (*)[]);
-void g() { int f(int (*)[2]); } /* { dg-error "previous declaration of 'f' was here" } */
+void g() { int f(int (*)[2]); } /* { dg-message "note: previous declaration of 'f' was here" } */
 int f(int (*)[3]); /* { dg-error "conflicting types for 'f'" } */
Index: gcc/testsuite/gcc.dg/pr27953.c
===================================================================
--- gcc/testsuite/gcc.dg/pr27953.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/pr27953.c	(working copy)
@@ -3,6 +3,6 @@
 void foo(struct A a) {}  /* { dg-warning "declared inside parameter list" } */
 /* { dg-warning "its scope is only" "" { target *-*-* } 3 } */
 /* { dg-error "incomplete type" "" { target *-*-* } 3 } */
 
 void foo() {}            /* { dg-error "redefinition" } */
-/* { dg-error "previous definition" "" { target *-*-* } 3 } */
+/* { dg-message "note: previous definition" "" { target *-*-* } 3 } */
Index: gcc/testsuite/gcc.dg/proto-1.c
===================================================================
--- gcc/testsuite/gcc.dg/proto-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/proto-1.c	(working copy)
@@ -1,5 +1,5 @@
 /* PR c/28502 */
 /* { dg-do compile } */
 
-void foo() {}      /* { dg-error "previous" } */
+void foo() {}      /* { dg-message "note: previous" } */
 void foo(void[]);  /* { dg-error "array of voids" } */
Index: gcc/testsuite/gcc.dg/decl-3.c
===================================================================
--- gcc/testsuite/gcc.dg/decl-3.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/decl-3.c	(working copy)
@@ -1,5 +1,5 @@
 /* PR c/9928 */
 /* { dg-do compile } */
 
-enum { CODES }; /* { dg-error "previous definition" } */
+enum { CODES }; /* { dg-message "note: previous definition" } */
 enum { CODES }; /* { dg-error "conflicting types|redeclaration of enumerator" } */
Index: gcc/testsuite/gcc.dg/redecl-13.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-13.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-13.c	(working copy)
@@ -3,7 +3,7 @@
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
 extern int a[];
-void f(void) { extern int a[10]; } /* { dg-error "previous declaration of 'a' was here" } */
+void f(void) { extern int a[10]; } /* { dg-message "note: previous declaration of 'a' was here" } */
 extern int a[5]; /* { dg-error "conflicting types for 'a'" } */
Index: gcc/testsuite/gcc.dg/pr15360-1.c
===================================================================
--- gcc/testsuite/gcc.dg/pr15360-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/pr15360-1.c	(working copy)
@@ -13,12 +13,12 @@ static int a;
 static int b;
 extern int b = 1; /* { dg-warning "initialized and declared" "extern init warning" } */
 static int b;
 static int b;
 
-static int c; /* { dg-error "previous declaration" "" } */
+static int c; /* { dg-message "note: previous declaration" "" } */
 int c; /* { dg-error "non-static" "correct error" } */
 
-static int d; /* { dg-error "previous declaration" "" } */
+static int d; /* { dg-message "note: previous declaration" "" } */
 int d = 1; /* { dg-error "non-static" "correct error" } */
 
 void foo (void) { extern int e = 1; } /* { dg-error "has both" "extern init in function" } */
Index: gcc/testsuite/gcc.dg/pr36901-1.c
===================================================================
--- gcc/testsuite/gcc.dg/pr36901-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901-1.c	(revision 0)
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+#include "pr36901-system.h"
+void foo(void)
+{
+  int s = sc;
+}
Index: gcc/testsuite/gcc.dg/redecl-15.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-15.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-15.c	(working copy)
@@ -5,10 +5,10 @@
 /* { dg-options "" } */
 
 void
 f (void)
 {
-  g(); /* { dg-warning "previous implicit declaration of 'g' was here" } */
+  g(); /* { dg-message "note: previous implicit declaration of 'g' was here" } */
   {
     void g(); /* { dg-warning "conflicting types for 'g'" } */
   }
 }
Index: gcc/testsuite/gcc.dg/enum-compat-1.c
===================================================================
--- gcc/testsuite/gcc.dg/enum-compat-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/enum-compat-1.c	(working copy)
@@ -23,10 +23,10 @@ enum e4 { B };
 
 enum e3 v3;
 enum e4 *p = &v3; /* { dg-warning "incompatible" "incompatible pointer" } */
 enum e3 *q = &v3;
 
-void g(enum e3); /* { dg-error "declaration" "error at first decl" } */
+void g(enum e3); /* { dg-message "note: previous declaration" "error at first decl" } */
 void g(enum e4); /* { dg-error "conflicting types" "error at second decl" } */
 
 void h(enum e3);
 void h(enum e3);
Index: gcc/testsuite/gcc.dg/pr36901-3.c
===================================================================
--- gcc/testsuite/gcc.dg/pr36901-3.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901-3.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+#include "pr36901.h"
+void foo(void)
+{
+  int s = sc;
+}
+/* { dg-message "file included" "In file included" { target *-*-* } 0 } */
+/* { dg-warning "overflow" "overflow" { target *-*-* } 0 } */
+/* { dg-error "overflow" "overflow" { target *-*-* } 0 } */
Index: gcc/testsuite/gcc.dg/dll-3.c
===================================================================
--- gcc/testsuite/gcc.dg/dll-3.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/dll-3.c	(working copy)
@@ -3,11 +3,11 @@
 /* { dg-do compile { target arm*-*-pe* } } */
 /* { dg-do compile { target i?86-pc-cygwin } } */
 /* { dg-do compile { target i?86-pc-mingw* } } */
 
 __declspec (dllimport) int foo1 ();
-__declspec (dllexport) int foo1 ();	/* { dg-warning "previous dllimport ignored" } */
+__declspec (dllexport) int foo1 ();	/* { dg-message "note: previous dllimport ignored" } */
 
 __declspec (dllexport) int foo2 ();
 __declspec (dllimport) int foo2 ();	/* { dg-warning "dllimport ignored" } */
 
 __declspec (dllexport) int foo1 () { return foo2 (); }
Index: gcc/testsuite/gcc.dg/array-5.c
===================================================================
--- gcc/testsuite/gcc.dg/array-5.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/array-5.c	(working copy)
@@ -11,11 +11,11 @@ char arr0[1];
    a gcc extension, but it should work like any other constant.  */
 extern char arr1[1];
 char arr1[1];
 extern char arr2[0];
 char arr2[0];
-extern char arr3[0];            /* { dg-error "previous declaration" } */
+extern char arr3[0];            /* { dg-message "note: previous declaration" } */
 char arr3[1];                   /* { dg-error "conflicting types" } */
 
 /* Variable size matches.  */
 void func(int n, int m)
 {
Index: gcc/testsuite/gcc.dg/Wredundant-decls-2.c
===================================================================
--- gcc/testsuite/gcc.dg/Wredundant-decls-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/Wredundant-decls-2.c	(working copy)
@@ -1,24 +1,24 @@
 /* Test for -Wredundant-decls warnings */
 /* { dg-do compile } */
 /* { dg-options "-Wredundant-decls" } */
 
-int j = 5; /* { dg-warning "previous" } */
+int j = 5; /* { dg-message "note: previous" } */
 int j;     /* { dg-warning "redundant" } */
 
 static int k;
-static int k = 5; /* { dg-warning "previous" } */
+static int k = 5; /* { dg-message "note: previous" } */
 static int k;     /* { dg-warning "redundant" } */
 
-static int l = 5; /* { dg-warning "previous" } */
+static int l = 5; /* { dg-message "note: previous" } */
 static int l;     /* { dg-warning "redundant" } */
 
-static int m;     /* { dg-warning "previous" } */
+static int m;     /* { dg-message "note: previous" } */
 static int m;     /* { dg-warning "redundant" } */
 static int m = 5;
 
-int n;           /* { dg-warning "previous" } */
+int n;           /* { dg-message "note: previous" } */
 int n;           /* { dg-warning "redundant" } */
 int n = 5; 
 
 static int o;
 static int o = 5;
Index: gcc/testsuite/gcc.dg/inline4.c
===================================================================
--- gcc/testsuite/gcc.dg/inline4.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/inline4.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Wall -std=gnu89" } */
 /* This testcase should fail since we're redefining foo in the same
    translation unit.  */
-int foo (void) { return 2; } /* { dg-error "previous definition of" } */
+int foo (void) { return 2; } /* { dg-message "note: previous definition of" } */
 extern inline int foo (void) { return 1; } /* { dg-error "redefinition of" } */
Index: gcc/testsuite/gcc.dg/redecl-2.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-2.c	(working copy)
@@ -5,60 +5,60 @@
 /* { dg-options "" } */
 
 void
 fa0 (void)
 {
-  int a0; /* { dg-error "previous declaration" } */
+  int a0; /* { dg-message "note: previous declaration" } */
   int a0; /* { dg-error "redeclaration" } */
 }
 
 void
 fa1 (void)
 {
-  int a1; /* { dg-error "previous declaration" } */
+  int a1; /* { dg-message "note: previous declaration" } */
   static int a1; /* { dg-error "redeclaration" } */
 }
 
 void
 fa2 (void)
 {
-  int a2; /* { dg-error "previous declaration" } */
+  int a2; /* { dg-message "note: previous declaration" } */
   extern int a2; /* { dg-error "follows declaration with no linkage" } */
 }
 
 void
 fa3 (void)
 {
-  static int a3; /* { dg-error "previous declaration" } */
+  static int a3; /* { dg-message "note: previous declaration" } */
   int a3; /* { dg-error "redeclaration" } */
 }
 
 void
 fa4 (void)
 {
-  static int a4; /* { dg-error "previous declaration" } */
+  static int a4; /* { dg-message "note: previous declaration" } */
   static int a4; /* { dg-error "redeclaration" } */
 }
 
 void
 fa5 (void)
 {
-  static int a5; /* { dg-error "previous declaration" } */
+  static int a5; /* { dg-message "note: previous declaration" } */
   extern int a5; /* { dg-error "follows declaration with no linkage" } */
 }
 
 void
 fa6 (void)
 {
-  extern int a6; /* { dg-error "previous declaration" } */
+  extern int a6; /* { dg-message "note: previous declaration" } */
   int a6; /* { dg-error "follows extern declaration" } */
 }
 
 void
 fa7 (void)
 {
-  extern int a7; /* { dg-error "previous declaration" } */
+  extern int a7; /* { dg-message "note: previous declaration" } */
   static int a7; /* { dg-error "follows extern declaration" } */
 }
 
 void
 fa8 (void)
Index: gcc/testsuite/gcc.dg/inline-14.c
===================================================================
--- gcc/testsuite/gcc.dg/inline-14.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/inline-14.c	(working copy)
@@ -1,21 +1,21 @@
 /* Check that you can't redefine a C99 inline function.  */
 /* { dg-do compile } */
 /* { dg-options "-std=c99" } */
 
 extern inline int func1 (void)
-{ /* { dg-error "previous definition" } */
+{ /* { dg-message "note: previous definition" } */
   return 1;
 }
 
 inline int func1 (void) /* { dg-error "redefinition" } */
 {
   return 1;
 }
 
 inline int func2 (void)
-{ /* { dg-error "previous definition" } */
+{ /* { dg-message "note: previous definition" } */
   return 2;
 }
 
 inline int func2 (void) /* { dg-error "redefinition" } */
 {
Index: gcc/testsuite/gcc.dg/tls/diag-3.c
===================================================================
--- gcc/testsuite/gcc.dg/tls/diag-3.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/tls/diag-3.c	(working copy)
@@ -1,11 +1,11 @@
 /* Report invalid extern and __thread combinations.  */
 /* { dg-require-effective-target tls } */
 
-extern int j;		/* { dg-error "previous declaration" } */
+extern int j;		/* { dg-message "note: previous declaration" } */
 __thread int j;		/* { dg-error "follows non-thread-local" } */
 
-extern __thread int i;	/* { dg-error "previous declaration" } */
+extern __thread int i;	/* { dg-message "note: previous declaration" } */
 int i;			/* { dg-error "follows thread-local" } */
 
 extern __thread int k;	/* This is fine.  */
 __thread int k;
Index: gcc/testsuite/gcc.dg/funcdef-var-2.c
===================================================================
--- gcc/testsuite/gcc.dg/funcdef-var-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/funcdef-var-2.c	(working copy)
@@ -4,8 +4,8 @@
 
 /* { dg-do compile } */
 /* { dg-options "-Wmissing-prototypes" } */
 
 int foo;
-/* { dg-error "previous declaration" "previous declaration" { target *-*-* } 8 } */
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } 8 } */
 void foo () {} /* { dg-error "redeclared as different kind of symbol" } */
 /* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } 10 } */
Index: gcc/testsuite/gcc.dg/20041213-1.c
===================================================================
--- gcc/testsuite/gcc.dg/20041213-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/20041213-1.c	(working copy)
@@ -1,33 +1,33 @@
 /* { dg-do compile } */
 /* { dg-options "" } */
 /* test redeclarations with void and implicit int */
-extern foo1(); /* { dg-error "previous declaration" } */
+extern foo1(); /* { dg-message "note: previous declaration" } */
 extern void foo1(); /* { dg-error "conflicting types" } */
 
-extern void foo2(); /* { dg-error "previous declaration" } */
+extern void foo2(); /* { dg-message "note: previous declaration" } */
 extern foo2(); /* { dg-error "conflicting types" } */
 
-void foo3() {} /* { dg-error "previous definition" } */
+void foo3() {} /* { dg-message "note: previous definition" } */
 extern foo3(); /* { dg-error "conflicting types" } */
 
-extern foo4(); /* { dg-error "previous declaration" } */
+extern foo4(); /* { dg-message "note: previous declaration" } */
 void foo4() {} /* { dg-error "conflicting types" } */
 
-extern void foo5(); /* { dg-warning "previous declaration" } */
+extern void foo5(); /* { dg-message "note: previous declaration" } */
 foo5() {} /* { dg-warning "conflicting types" } */
 
-foo6() {} /* { dg-error "previous definition" } */
+foo6() {} /* { dg-message "note: previous definition" } */
 extern void foo6(); /* { dg-error "conflicting types" } */
 
-foo7() {} /* { dg-error "previous definition" } */
+foo7() {} /* { dg-message "note: previous definition" } */
 void foo7() {} /* { dg-error "conflicting types" } */
 
-void foo8() {} /* { dg-error "previous definition" } */
+void foo8() {} /* { dg-message "note: previous definition" } */
 foo8() {} /* { dg-error "conflicting types" } */
 
-int use9() { foo9(); } /* { dg-warning "previous implicit declaration" } */
+int use9() { foo9(); } /* { dg-message "note: previous implicit declaration" } */
 extern void foo9(); /* { dg-warning "conflicting types" } */
 
-int use10() { foo10(); } /* { dg-warning "previous implicit declaration" } */
+int use10() { foo10(); } /* { dg-message "note: previous implicit declaration" } */
 void foo10() {} /* { dg-warning "conflicting types" } */
 
Index: gcc/testsuite/gcc.dg/old-style-then-proto-1.c
===================================================================
--- gcc/testsuite/gcc.dg/old-style-then-proto-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/old-style-then-proto-1.c	(working copy)
@@ -5,40 +5,40 @@
 /* { dg-options "" } */
 
 void f1() {}
 void f1(void); /* { dg-warning "prototype for 'f1' follows non-prototype definition" } */
 
-void f2() {} /* { dg-error "previous definition of 'f2' was here" } */
+void f2() {} /* { dg-message "note: previous definition of 'f2' was here" } */
 void f2(int); /* { dg-error "prototype for 'f2' declares more arguments than previous old-style definition" } */
 
-void f3(a) int a; {} /* { dg-error "previous definition of 'f3' was here" } */
+void f3(a) int a; {} /* { dg-message "note: previous definition of 'f3' was here" } */
 void f3(void); /* { dg-error "prototype for 'f3' declares fewer arguments than previous old-style definition" } */
 
 void f4(a) int a; {}
 void f4(int); /* { dg-warning "prototype for 'f4' follows non-prototype definition" } */
 
-void f5(a) int a; {} /* { dg-error "previous definition of 'f5' was here" } */
+void f5(a) int a; {} /* { dg-message "note: previous definition of 'f5' was here" } */
 void f5(int, int); /* { dg-error "prototype for 'f5' declares more arguments than previous old-style definition" } */
 
-void f6(a) int a; {} /* { dg-error "previous definition of 'f6' was here" } */
+void f6(a) int a; {} /* { dg-message "note: previous definition of 'f6' was here" } */
 void f6(int, ...); /* { dg-error "conflicting types for 'f6'" } */
 
-void f7(a, b) int a, b; {} /* { dg-error "previous definition of 'f7' was here" } */
+void f7(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f7' was here" } */
 void f7(int); /* { dg-error "prototype for 'f7' declares fewer arguments than previous old-style definition" } */
 
-void f8(a, b) int a, b; {} /* { dg-error "previous definition of 'f8' was here" } */
+void f8(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f8' was here" } */
 void f8(int, ...); /* { dg-error "conflicting types for 'f8'" } */
 
 void f9(a, b) int a, b; {}
 void f9(int, int); /* { dg-warning "prototype for 'f9' follows non-prototype definition" } */
 
-void f10(a, b) int a, b; {} /* { dg-error "previous definition of 'f10' was here" } */
+void f10(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f10' was here" } */
 void f10(int, long); /* { dg-error "prototype for 'f10' declares argument 2 with incompatible type" } */
 
-void f11(a, b) int a, b; {} /* { dg-error "previous definition of 'f11' was here" } */
+void f11(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f11' was here" } */
 void f11(long, int); /* { dg-error "prototype for 'f11' declares argument 1 with incompatible type" } */
 
 void f12(a, b) const int a; volatile int b; {}
 void f12(volatile int, const int); /* { dg-warning "prototype for 'f12' follows non-prototype definition" } */
 
-void f13(a) const int a[2][2]; {} /* { dg-error "previous definition of 'f13' was here" } */
+void f13(a) const int a[2][2]; {} /* { dg-message "note: previous definition of 'f13' was here" } */
 void f13(volatile int [2][2]); /* { dg-error "prototype for 'f13' declares argument 1 with incompatible type" } */
Index: gcc/testsuite/gcc.dg/decl-2.c
===================================================================
--- gcc/testsuite/gcc.dg/decl-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/decl-2.c	(working copy)
@@ -5,11 +5,11 @@
 /* { dg-do compile } */
 
 void foo(void)
 {
   char
-    c	/* { dg-error "previous declaration" } */
+    c	/* { dg-message "note: previous declaration" } */
     ;
   int i;
   int
     c	/* { dg-error "conflicting types" } */
     = i;
Index: gcc/testsuite/gcc.dg/redecl-12.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-12.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-12.c	(working copy)
@@ -3,7 +3,7 @@
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
 extern int a[];
-void f(void) { extern int a[]; extern int a[10]; } /* { dg-error "previous declaration of 'a' was here" } */
+void f(void) { extern int a[]; extern int a[10]; } /* { dg-message "note: previous declaration of 'a' was here" } */
 extern int a[5]; /* { dg-error "conflicting types for 'a'" } */
Index: gcc/testsuite/gcc.dg/decl-4.c
===================================================================
--- gcc/testsuite/gcc.dg/decl-4.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/decl-4.c	(working copy)
@@ -1,10 +1,10 @@
 /* Redeclaration of parameters is an error.  PR 13728.  */
 /* { dg-do compile } */
 
-void f (int fred,	/* { dg-error "previous definition" "" } */
+void f (int fred,	/* { dg-message "note: previous definition" "" } */
 	int fred);	/* { dg-error "redefinition of parameter" "" } */
 
-void f2 (int fred,	/* { dg-error "previous definition" "" } */
+void f2 (int fred,	/* { dg-message "note: previous definition" "" } */
 	 int fred)	/* { dg-error "redefinition of parameter" "" } */
 {
 }
Index: gcc/testsuite/gcc.dg/pr36901-system.h
===================================================================
--- gcc/testsuite/gcc.dg/pr36901-system.h	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901-system.h	(revision 0)
@@ -0,0 +1,3 @@
+#pragma GCC system_header
+#include "pr36901.h"
+
Index: gcc/testsuite/gcc.dg/Wshadow-1.c
===================================================================
--- gcc/testsuite/gcc.dg/Wshadow-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/Wshadow-1.c	(working copy)
@@ -8,11 +8,11 @@
 int decl1;			/* { dg-warning "shadowed declaration" } */
 void foo (double decl1)		/* { dg-warning "shadows a global decl" } */
 {				
 }
 
-void foo1 (int d)		/* { dg-error "previous definition" } */
+void foo1 (int d)		/* { dg-message "note: previous definition" } */
 {
   double d;	 /* { dg-bogus "warning" "warning in place of error" } */
   /* { dg-error "redeclared as different" "" { target *-*-* } 15 } */
 }
 
Index: gcc/testsuite/gcc.dg/transparent-union-2.c
===================================================================
--- gcc/testsuite/gcc.dg/transparent-union-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/transparent-union-2.c	(working copy)
@@ -3,16 +3,16 @@
 /* { dg-options "-std=gnu99" } */
 
 typedef union { int *i; long *l; } U
   __attribute__((transparent_union));
 
-extern void f0 (U);		/* { dg-error "previous declaration" } */
+extern void f0 (U);		/* { dg-message "note: previous declaration" } */
 extern void f0 (void *);	/* { dg-error "conflicting types" } */
 
-extern void f1 (U);		/* { dg-error "previous declaration" } */
+extern void f1 (U);		/* { dg-message "note: previous declaration" } */
 extern void f1 (unsigned long);	/* { dg-error "conflicting types" } */
 
-extern void f2 (void *);	/* { dg-error "previous declaration" } */
+extern void f2 (void *);	/* { dg-message "note: previous declaration" } */
 extern void f2 (U);		/* { dg-error "conflicting types" } */
 
-extern void f3 (unsigned long);	/* { dg-error "previous declaration" } */
+extern void f3 (unsigned long);	/* { dg-message "note: previous declaration" } */
 extern void f3 (U);		/* { dg-error "conflicting types" } */
Index: gcc/testsuite/gcc.dg/pr36901-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pr36901-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901-2.c	(revision 0)
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors -w" } */
+#include "pr36901.h"
+void foo(void)
+{
+  int s = sc;
+}
Index: gcc/testsuite/gcc.dg/visibility-7.c
===================================================================
--- gcc/testsuite/gcc.dg/visibility-7.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/visibility-7.c	(working copy)
@@ -3,10 +3,10 @@
 /* { dg-require-visibility "protected" } */
 /* { dg-final { scan-hidden "xyzzy" } } */
 
 extern int 
 __attribute__((visibility ("hidden")))
-xyzzy; /* { dg-warning "previous declaration" "" } */
+xyzzy; /* { dg-message "note: previous declaration" "" } */
 
 int 
 __attribute__((visibility ("protected")))
 xyzzy = 5; /* { dg-warning "different visibility" "" } */
Index: gcc/testsuite/gcc.dg/dll-2.c
===================================================================
--- gcc/testsuite/gcc.dg/dll-2.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/dll-2.c	(working copy)
@@ -9,14 +9,14 @@
    and functions.  In C++, it only works for functions.  */
 
 /* { dg-require-dll "" } */
 
 __declspec (dllimport) int foo1 ();
-__declspec (dllexport) int foo1 ();	/* { dg-warning "previous dllimport ignored" } */
+__declspec (dllexport) int foo1 ();	/* { dg-message "note: previous dllimport ignored" } */
 __declspec (dllexport) int foo2 ();
 __declspec (dllimport) int foo2 ();	/* { dg-warning "dllimport ignored" } */
 
 __declspec (dllimport) int bar1;
-__declspec (dllexport) int bar1;	/* { dg-warning "previous dllimport ignored" } */
+__declspec (dllexport) int bar1;	/* { dg-message "note: previous dllimport ignored" } */
 
 __declspec (dllexport) int bar2;
 __declspec (dllimport) int bar2;	/* { dg-warning "dllimport ignored" } */
Index: gcc/testsuite/gcc.dg/redecl-16.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-16.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-16.c	(working copy)
@@ -12,7 +12,7 @@ extern IAP a[];
 void
 f (void)
 {
   extern IA5P a[];
 }
-IAP a[] = { 0 };	/* { dg-error "previous definition" } */
+IAP a[] = { 0 };	/* { dg-message "note: previous definition" } */
 extern IA10P a[];	/* { dg-error "conflicting types" } */
Index: gcc/testsuite/gcc.dg/inline1.c
===================================================================
--- gcc/testsuite/gcc.dg/inline1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/inline1.c	(working copy)
@@ -1,8 +1,8 @@
 /* { dg-do compile } */
 /* { dg-options "-Wall -std=gnu89" } */
 /* This test is expected to fail with an error for the redefinition of foo.
    This violates the constraint of 6.9#3 (no more than one external definition
    of an identifier with internal linkage in the same translation unit).  */
-static inline int foo(void) { return 1; } /* { dg-error "previous definition of" } */
+static inline int foo(void) { return 1; } /* { dg-message "note: previous definition of" } */
 static inline int foo(void) { return 0; } /* { dg-error "redefinition of" } */
 
Index: gcc/testsuite/gcc.dg/pr36901-4.c
===================================================================
--- gcc/testsuite/gcc.dg/pr36901-4.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901-4.c	(revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors -Wsystem-headers" } */
+#include "pr36901-system.h"
+void foo(void)
+{
+  int s = sc;
+}
+/* { dg-message "from " "In file included" { target *-*-* } 0 } */
+/* { dg-warning "overflow" "overflow" { target *-*-* } 0 } */
+/* { dg-error "overflow" "overflow" { target *-*-* } 0 } */
+/* { dg-error "#include_next is a GCC extension" "#include_next" { target *-*-* } 0 } */
Index: gcc/testsuite/gcc.dg/decl-8.c
===================================================================
--- gcc/testsuite/gcc.dg/decl-8.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/decl-8.c	(working copy)
@@ -1,10 +1,10 @@
 /* Test diagnostics for duplicate typedefs.  Basic diagnostics.  */
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
-typedef int I; /* { dg-error "previous declaration of 'I' was here" } */
+typedef int I; /* { dg-message "note: previous declaration of 'I' was here" } */
 typedef int I; /* { dg-error "redefinition of typedef 'I'" } */
 
-typedef int I1; /* { dg-error "previous declaration of 'I1' was here" } */
+typedef int I1; /* { dg-message "note: previous declaration of 'I1' was here" } */
 typedef long I1; /* { dg-error "conflicting types for 'I1'" } */
Index: gcc/testsuite/gcc.dg/nested-redef-1.c
===================================================================
--- gcc/testsuite/gcc.dg/nested-redef-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/nested-redef-1.c	(working copy)
@@ -34,11 +34,11 @@ enum e0 {
   E0 = sizeof(enum e0 { E1 }) /* { dg-error "nested redefinition of 'enum e0'" } */
 };
 
 enum e1 {
   E2 = sizeof(enum e2 { E2 }), /* { dg-error "redeclaration of enumerator 'E2'" } */
-  /* { dg-error "previous definition" "previous E2" { target *-*-* } 38 } */
+  /* { dg-message "note: previous definition" "previous E2" { target *-*-* } 38 } */
   E3
 };
 
 enum e3;
 enum e3 { E4 = 0 };
Index: gcc/testsuite/gcc.dg/inline3.c
===================================================================
--- gcc/testsuite/gcc.dg/inline3.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/inline3.c	(working copy)
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-Wall -std=gnu89" } */
 /* This testcase should fail since we're redefining foo in the same
    translation unit.  */
 extern inline int foo(void) { return 0; }
-inline int foo (void) { return 1; } /* { dg-error "previous definition of" } */
+inline int foo (void) { return 1; } /* { dg-message "note: previous definition of" } */
 int foo (void) { return 2; } /* { dg-error "redefinition of" } */
Index: gcc/testsuite/gcc.dg/redecl-1.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-1.c	(working copy)
@@ -7,12 +7,12 @@
 /* { dg-do compile } */
 /* { dg-options "-std=c89 -pedantic -Wall -Wno-unused" } */
 
 /* Extern at function scope, clashing with extern at file scope */
 
-extern int foo1;		/* { dg-error "previous" } */
-extern int bar1(int);		/* { dg-error "previous" } */
+extern int foo1;		/* { dg-message "note: previous" } */
+extern int bar1(int);		/* { dg-message "note: previous" } */
 
 void test1(void)
 {
   extern double foo1;		/* { dg-error "conflict" } */
   extern double bar1(double);	/* { dg-error "conflict" } */
@@ -20,12 +20,12 @@ void test1(void)
 
 /* Extern at file scope, clashing with extern at function scope */
 
 void test2(void)
 {
-  extern double foo2;		/* { dg-error "previous" } */
-  extern double bar2(double);	/* { dg-error "previous" } */
+  extern double foo2;		/* { dg-message "note: previous" } */
+  extern double bar2(double);	/* { dg-message "note: previous" } */
 }
 
 extern int foo2;		/* { dg-error "conflict" } */
 extern int bar2(int);		/* { dg-error "conflict" } */
 
@@ -34,13 +34,13 @@ extern int bar2(int);		/* { dg-error "co
 
 typedef float baz3;		/* { dg-bogus } */
 
 void prime3(void)
 {
-  extern int foo3;		/* { dg-error "previous" } */
-  extern int bar3(int);		/* { dg-error "previous" } */
-  extern int baz3;		/* { dg-error "previous" } */
+  extern int foo3;		/* { dg-message "note: previous" } */
+  extern int bar3(int);		/* { dg-message "note: previous" } */
+  extern int baz3;		/* { dg-message "note: previous" } */
 }
 
 void test3(void)
 {
   extern double foo3;		/* { dg-error "conflict" } */
@@ -56,47 +56,47 @@ void prime4(void)
 }
 
 void test4(void)
 {
   extern double bar4(double);	/* { dg-error "conflict" } */
-/* { dg-error "previous implicit declaration" "" { target *-*-* } 55 } */
+/* { dg-message "note: previous implicit declaration" "" { target *-*-* } 55 } */
 }
 
 /* Implicit decl, clashing with extern at previous function scope.  */
 
 void prime5(void)
 {
   extern double bar5(double);	/* { dg-message "note: previous declaration" "" } */
-} /* { dg-error "previous implicit declaration" "" { target *-*-* } 68 } */
+} /* { dg-message "note: previous implicit declaration" "" { target *-*-* } 68 } */
 
 void test5(void)
 {
   bar5(1);			/* { dg-warning "implicit declaration of function" } */
 } /* { dg-error "incompatible implicit declaration" "" { target *-*-* } 73 } */
 
 /* Extern then static, both at file scope.  */
 
-extern int test6(int);		/* { dg-error "previous" "" } */
+extern int test6(int);		/* { dg-message "note: previous" "" } */
 static int test6(int x)		/* { dg-error "follows non-static" } */
 { return x; }
 
 
 /* Extern then static, extern at previous function scope.  */
 
 void prime7(void)
 {
-  extern int test7(int);	/* { dg-error "previous" "" } */
+  extern int test7(int);	/* { dg-message "note: previous" "" } */
 }
 
 static int test7(int x)		/* { dg-error "follows non-static" } */
 { return x; }
 
 /* Implicit decl then static.  */
 
 void prime8(void)
 {
-  test8();			/* { dg-error "previous" "" } */
+  test8();			/* { dg-message "note: previous" "" } */
                                 /* { dg-warning "implicit" "implicit" { target *-*-* } 97 } */
 }
 
 static int test8(int x)		/* { dg-error "follows non-static" } */
 { return x; }
Index: gcc/testsuite/gcc.dg/pr36901.h
===================================================================
--- gcc/testsuite/gcc.dg/pr36901.h	(revision 0)
+++ gcc/testsuite/gcc.dg/pr36901.h	(revision 0)
@@ -0,0 +1,2 @@
+#include <limits.h>
+static int sc = INT_MAX + 1; 
Index: gcc/testsuite/gcc.dg/inline5.c
===================================================================
--- gcc/testsuite/gcc.dg/inline5.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/inline5.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Wall -std=gnu89" } */
 /* This testcase should fail since we're redefining foo in the same
    translation unit.  */
-extern inline int foo (void) { return 2; } /* { dg-error "previous definition of" } */
+extern inline int foo (void) { return 2; } /* { dg-message "note: previous definition of" } */
 extern inline int foo (void) { return 1; } /* { dg-error "redefinition of" } */
Index: gcc/testsuite/gcc.dg/pr35899.c
===================================================================
--- gcc/testsuite/gcc.dg/pr35899.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/pr35899.c	(working copy)
@@ -3,11 +3,11 @@
 /* { dg-options "-O2" } */
 
 int
 foo (void)
 {
-  int a = bar ();	/* { dg-warning "previous implicit declaration" } */
+  int a = bar ();	/* { dg-message "note: previous implicit declaration" } */
   return a;
 }
 
 void
 bar (void)		/* { dg-warning "conflicting types for" } */
Index: gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c
===================================================================
--- gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/noncompile/label-lineno-1.c	(working copy)
@@ -2,11 +2,11 @@
    by Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/23/2000.  */
 
 void
 foo(int i)
 {
- my_label: /* { dg-error "previous definition" "prev label" } */
+ my_label: /* { dg-message "note: previous definition" "prev label" } */
 
   i++;
 
  my_label: /* { dg-error "duplicate label" "label lineno" } */
 
Index: gcc/testsuite/gcc.dg/noncompile/label-1.c
===================================================================
--- gcc/testsuite/gcc.dg/noncompile/label-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/noncompile/label-1.c	(working copy)
@@ -26,19 +26,19 @@ void c(void)
 }
 
 /* can't have two labels with the same name in the same function */
 void d(void)
 {
- l: dummy();  /* { dg-error "previous definition" "prev def same scope" } */
+ l: dummy();  /* { dg-message "note: previous definition" "prev def same scope" } */
  l: dummy();  /* { dg-error "duplicate label" "dup label same scope" } */
  goto l;
 }
 
 /* even at different scopes */
 void e(void)
 {
- l: dummy();	/* { dg-error "previous definition"  "prev def diff scope" } */
+ l: dummy();	/* { dg-message "note: previous definition"  "prev def diff scope" } */
   {
   l: dummy();	/* { dg-error "duplicate label" "dup label diff scope" } */
   }
   goto l;
 }
@@ -148,11 +148,11 @@ void m(void)
 /* and that means the nested function cannot have its own label with
    the same name as an outer label declared with __label__ */
 
 void n(void)
 {
-  __label__ l; /* { dg-error "previous declaration" "outer label decl" } */
+  __label__ l; /* { dg-message "note: previous declaration" "outer label decl" } */
   void nest(void)
     {
     l: goto l;  /* { dg-error "duplicate label" "inner label defn" } */
     }
 
Index: gcc/testsuite/gcc.dg/noncompile/20020220-1.c
===================================================================
--- gcc/testsuite/gcc.dg/noncompile/20020220-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/noncompile/20020220-1.c	(working copy)
@@ -4,9 +4,9 @@
 int foo (const char*, const char*);
 
 void bar (void)
 {
   const char *s = "bar";
-  int i;			/* { dg-error "previous declaration" } */
+  int i;			/* { dg-message "note: previous declaration" } */
   int size = 2;
   int i = foo (s, s + size);	/* { dg-error "redeclaration of" } */
 }
Index: gcc/testsuite/gcc.dg/noncompile/redecl-1.c
===================================================================
--- gcc/testsuite/gcc.dg/noncompile/redecl-1.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/noncompile/redecl-1.c	(working copy)
@@ -2,8 +2,8 @@
 /* by Alexandre Oliva  <aoliva@redhat.com> */
 
 int
 foo ()
 {
-  int bar; /* { dg-error "previous.*decl" "previous.*decl" } */
+  int bar; /* { dg-message "note: previous.*decl" "previous.*decl" } */
   volatile int bar; /* { dg-error "conflicting type qualifiers" "conflicting type qualifiers" } */
 }
Index: gcc/testsuite/gcc.dg/redecl-5.c
===================================================================
--- gcc/testsuite/gcc.dg/redecl-5.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/redecl-5.c	(working copy)
@@ -5,11 +5,11 @@
 /* { dg-options "-std=c89" } */
 
 void
 f (void)
 {
-  long z(); /* { dg-error "previous implicit declaration" } */
+  long z(); /* { dg-message "note: previous implicit declaration" } */
 }
 
 void
 g (void)
 {
Index: gcc/testsuite/gcc.dg/qual-return-3.c
===================================================================
--- gcc/testsuite/gcc.dg/qual-return-3.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/qual-return-3.c	(working copy)
@@ -4,11 +4,11 @@
 
 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
-int foo (); /* { dg-error "previous declaration" "different qualifiers" } */
+int foo (); /* { dg-message "note: previous declaration" "different qualifiers" } */
 const int foo () { return 0; } /* { dg-error "conflicting types" "different qualifiers" } */
 
 void bar (void);
 volatile void bar () { } /* { dg-warning "qualified|volatile" "different qualifiers" } */
 
Index: gcc/testsuite/gcc.dg/label-decl-4.c
===================================================================
--- gcc/testsuite/gcc.dg/label-decl-4.c	(revision 138311)
+++ gcc/testsuite/gcc.dg/label-decl-4.c	(working copy)
@@ -5,10 +5,10 @@
 
 void
 f (void)
 {
   __label__ a, b, a; /* { dg-error "duplicate label declaration 'a'" } */
-  /* { dg-error "previous declaration of 'a' was here" "previous" { target *-*-* } 9 } */
-  __label__ c; /* { dg-error "previous declaration of 'c' was here" } */
+  /* { dg-message "note: previous declaration of 'a' was here" "previous" { target *-*-* } 9 } */
+  __label__ c; /* { dg-message "note: previous declaration of 'c' was here" } */
   __label__ c; /* { dg-error "duplicate label declaration 'c'" } */
   return;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]