diff mbox

conditional notes after 'warning_at'

Message ID CAFH4-dhTGO36+OcRvpusJ7ZAh0hNaa7fUKXWO-gnvE9iDuDEqw@mail.gmail.com
State New
Headers show

Commit Message

Fabien Chêne April 4, 2014, 7:19 p.m. UTC
Hi,

next victim of the cleanup: warning_at.
Tested x86_64 linux without regressions. OK to commit ?

cp/ChangeLog

2014-04-04  Fabien Chêne  <fabien@gcc.gnu.org>

    * decl.c (duplicate_decls): Check for the return of warning_at
    before emitting a note.
    (warn_misplaced_attr_for_class_type): Likewise.
    (check_tag_decl): Likewise.

Comments

Jason Merrill April 4, 2014, 7:34 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(révision 209117)
+++ gcc/cp/decl.c	(copie de travail)
@@ -1648,10 +1648,10 @@  duplicate_decls (tree newdecl, tree oldd
 	       && prototype_p (TREE_TYPE (newdecl)))
 	{
 	  /* Prototype decl follows defn w/o prototype.  */
-	  warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
-		      "prototype specified for %q#D", newdecl);
-	  inform (DECL_SOURCE_LOCATION (olddecl),
-		  "previous non-prototype definition here");
+	  if (warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
+			  "prototype specified for %q#D", newdecl))
+	    inform (DECL_SOURCE_LOCATION (olddecl),
+		    "previous non-prototype definition here");
 	}
       else if (VAR_OR_FUNCTION_DECL_P (olddecl)
 	       && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl))
@@ -4242,12 +4242,12 @@  warn_misplaced_attr_for_class_type (sour
 {
   gcc_assert (OVERLOAD_TYPE_P (class_type));
 
-  warning_at (location, OPT_Wattributes,
-	      "attribute ignored in declaration "
-	      "of %q#T", class_type);
-  inform (location,
-	  "attribute for %q#T must follow the %qs keyword",
-	  class_type, class_key_or_enum_as_string (class_type));
+  if (warning_at (location, OPT_Wattributes,
+		  "attribute ignored in declaration "
+		  "of %q#T", class_type))
+    inform (location,
+	    "attribute for %q#T must follow the %qs keyword",
+	    class_type, class_key_or_enum_as_string (class_type));
 }
 
 /* Make sure that a declaration with no declarator is well-formed, i.e.
@@ -4374,12 +4374,12 @@  check_tag_decl (cp_decl_specifier_seq *d
 	       No attribute-specifier-seq shall appertain to an explicit
 	       instantiation.  */
 	{
-	  warning_at (loc, OPT_Wattributes,
-		      "attribute ignored in explicit instantiation %q#T",
-		      declared_type);
-	  inform (loc,
-		  "no attribute can be applied to "
-		  "an explicit instantiation");
+	  if (warning_at (loc, OPT_Wattributes,
+			  "attribute ignored in explicit instantiation %q#T",
+			  declared_type))
+	    inform (loc,
+		    "no attribute can be applied to "
+		    "an explicit instantiation");
 	}
       else
 	warn_misplaced_attr_for_class_type (loc, declared_type);