diff options
author | Martin Sebor <msebor@redhat.com> | 2018-02-14 22:02:43 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-02-14 15:02:43 -0700 |
commit | fba303ed8c190cc2b8695d737efd7af409596398 (patch) | |
tree | 002e7f40bf82a0465272aea8e6c554cac2590d82 /gcc/attribs.c | |
parent | ee3bb1b7a2f73c9ccc99b0861e8a3408d408ca2d (diff) | |
download | gcc-fba303ed8c190cc2b8695d737efd7af409596398.tar.gz |
PR middle-end/84108 - incorrect -Wattributes warning for packed/aligned conflict on struct members
gcc/ChangeLog:
PR c/84108
* attribs.c (diag_attr_exclusions): Consider the exclusion(s)
that correspond to the kind of a declaration.
gcc/testsuite/ChangeLog:
PR c/84108
* gcc.dg/Wattributes-8.c: New test.
From-SVN: r257674
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r-- | gcc/attribs.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c index 2cac9c403b4..140863be1d9 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -410,6 +410,22 @@ diag_attr_exclusions (tree last_decl, tree node, tree attrname, if (!lookup_attribute (excl->name, attrs[i])) continue; + /* An exclusion may apply either to a function declaration, + type declaration, or a field/variable declaration, or + any subset of the three. */ + if (TREE_CODE (node) == FUNCTION_DECL + && !excl->function) + continue; + + if (TREE_CODE (node) == TYPE_DECL + && !excl->type) + continue; + + if ((TREE_CODE (node) == FIELD_DECL + || TREE_CODE (node) == VAR_DECL) + && !excl->variable) + continue; + found = true; /* Print a note? */ |