From 090ec70209ce4d706bb618d5efbc1325ade0341f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabien=20Ch=C3=AAne?= Date: Fri, 4 Apr 2014 23:36:11 +0200 Subject: [PATCH] decl.c (duplicate_decls): Check for the return of warning_at before emitting a note. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2014-04-04 Fabien Chêne * 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. From-SVN: r209131 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 76f7aa9ea34..4a491cc0228 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-04-04 Fabien Chêne + + * 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. + 2014-04-04 Paolo Carlini PR c++/58207 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d70a8656e92..34005944246 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1648,10 +1648,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) && 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)) @@ -4241,12 +4241,12 @@ warn_misplaced_attr_for_class_type (source_location location, { 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. @@ -4373,12 +4373,12 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, 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); -- 2.30.2