diff options
author | Marek Polacek <polacek@redhat.com> | 2016-05-10 10:22:16 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-05-10 10:22:16 +0000 |
commit | cf68d92c7bb339d89426558cae2ad731ae8f0508 (patch) | |
tree | 2484ab32479d623f763dc2a8064fdd7d61b77910 /gcc/c/c-decl.c | |
parent | bf1abda157fc40b9020da82ea35c087f2a442a95 (diff) | |
download | gcc-cf68d92c7bb339d89426558cae2ad731ae8f0508.zip gcc-cf68d92c7bb339d89426558cae2ad731ae8f0508.tar.gz gcc-cf68d92c7bb339d89426558cae2ad731ae8f0508.tar.bz2 |
re PR c/70255 (change of the order of summation of floating point numbers despite no-associative-math)
PR c/70255
* c-decl.c (diagnose_mismatched_decls): Warn for optimize attribute
on a declaration following the definition.
* gcc.dg/attr-opt-1.c: New test.
From-SVN: r236071
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 7094efc..9c09536 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -2228,6 +2228,18 @@ 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))) |