From fba303ed8c190cc2b8695d737efd7af409596398 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 14 Feb 2018 22:02:43 +0000 Subject: 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 --- gcc/attribs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/attribs.c') diff --git a/gcc/attribs.c b/gcc/attribs.c index 2cac9c4..140863b 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? */ -- cgit v1.1