aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-05-11 17:07:37 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-05-11 17:07:37 +0000
commit5c3a10fbc1d4e91287b635d6ff068c8f80dff8cd (patch)
treee5ba1d4738473b86a982524a9ab092d6e15fa106 /gcc/c
parent7cfb065b0e75bf8dab8337d1c3ce33f79110226f (diff)
downloadgcc-5c3a10fbc1d4e91287b635d6ff068c8f80dff8cd.zip
gcc-5c3a10fbc1d4e91287b635d6ff068c8f80dff8cd.tar.gz
gcc-5c3a10fbc1d4e91287b635d6ff068c8f80dff8cd.tar.bz2
re PR c++/71024 (Missing warning for contradictory attributes)
PR c++/71024 * c-common.c (diagnose_mismatched_attributes): New function. * c-common.h (diagnose_mismatched_attributes): Declare. * c-decl.c (diagnose_mismatched_decls): Factor out code to diagnose_mismatched_attributes and call it. * decl.c (duplicate_decls): Call diagnose_mismatched_decls. * c-c++-common/attributes-3.c: New test. From-SVN: r236129
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c50
2 files changed, 7 insertions, 49 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 9387c73..7044400 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-11 Marek Polacek <polacek@redhat.com>
+
+ PR c++/71024
+ * c-decl.c (diagnose_mismatched_decls): Factor out code to
+ diagnose_mismatched_attributes and call it.
+
2016-05-10 Marek Polacek <polacek@redhat.com>
PR c/70255
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 9c09536..6ba0e0e 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -2227,55 +2227,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
}
if (TREE_CODE (newdecl) == FUNCTION_DECL)
- {
- tree a1 = lookup_attribute ("optimize", DECL_ATTRIBUTES (olddecl));
- tree a2 = lookup_attribute ("optimize", DECL_ATTRIBUTES (newdecl));
- /* An optimization attribute applied on a declaration after the
- definition is likely not what the user wanted. */
- if (a2 != NULL_TREE
- && DECL_SAVED_TREE (olddecl) != NULL_TREE
- && (a1 == NULL_TREE || !attribute_list_equal (a1, a2)))
- warned |= warning (OPT_Wattributes,
- "optimization attribute on %qD follows "
- "definition but the attribute doesn%'t match",
- newdecl);
-
- /* Diagnose inline __attribute__ ((noinline)) which is silly. */
- if (DECL_DECLARED_INLINE_P (newdecl)
- && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
- 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)))
- warned |= warning (OPT_Wattributes,
- "declaration of %q+D with attribute "
- "noinline follows inline declaration ", newdecl);
- else if (lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))
- && lookup_attribute ("always_inline", DECL_ATTRIBUTES (olddecl)))
- warned |= warning (OPT_Wattributes,
- "declaration of %q+D with attribute "
- "%qs follows declaration with attribute %qs",
- newdecl, "noinline", "always_inline");
- else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (newdecl))
- && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
- warned |= warning (OPT_Wattributes,
- "declaration of %q+D with attribute "
- "%qs follows declaration with attribute %qs",
- newdecl, "always_inline", "noinline");
- else if (lookup_attribute ("cold", DECL_ATTRIBUTES (newdecl))
- && lookup_attribute ("hot", DECL_ATTRIBUTES (olddecl)))
- warned |= warning (OPT_Wattributes,
- "declaration of %q+D with attribute %qs follows "
- "declaration with attribute %qs", newdecl, "cold",
- "hot");
- else if (lookup_attribute ("hot", DECL_ATTRIBUTES (newdecl))
- && lookup_attribute ("cold", DECL_ATTRIBUTES (olddecl)))
- warned |= warning (OPT_Wattributes,
- "declaration of %q+D with attribute %qs follows "
- "declaration with attribute %qs", newdecl, "hot",
- "cold");
- }
+ warned |= diagnose_mismatched_attributes (olddecl, newdecl);
else /* PARM_DECL, VAR_DECL */
{
/* Redeclaration of a parameter is a constraint violation (this is