aboutsummaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2019-07-18 00:38:45 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2019-07-18 00:38:45 +0000
commitdea78431676f0104f5467788e8e78fc05c3ab981 (patch)
treeb343f18a6534f518028fdf53783d6d934389ab2d /gcc/attribs.c
parent8ea3c020a234e25d4a976e69902208f744c0819c (diff)
downloadgcc-dea78431676f0104f5467788e8e78fc05c3ab981.zip
gcc-dea78431676f0104f5467788e8e78fc05c3ab981.tar.gz
gcc-dea78431676f0104f5467788e8e78fc05c3ab981.tar.bz2
-Wmissing-attributes: check that we avoid duplicates and false positives
The initial patch for PR 81824 fixed various possibilities of -Wmissing-attributes reporting duplicates and false positives. The test that avoided them was a little obscure, though, so this patch rewrites it into a more self-evident form. The patch also adds a testcase that already passed, but that explicitly covers some of the possibilities of reporting duplicates and false positives that preexisting tests did not cover. for gcc/ChangeLog PR middle-end/81824 * attribs.c (decls_mismatched_attributes): Simplify the logic that avoids duplicates and false positives. for gcc/testsuite/ChangeLog PR middle-end/81824 * g++.dg/Wmissing-attributes-1.C: New. Some of its fragments are from Martin Sebor. From-SVN: r273563
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 8e54016..f4777c6 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -1931,15 +1931,19 @@ decls_mismatched_attributes (tree tmpl, tree decl, tree attrlist,
if (!has_attribute (tmpls[j], tmpl_attrs[j], blacklist[i]))
continue;
+ bool found = false;
unsigned kmax = 1 + !!decl_attrs[1];
for (unsigned k = 0; k != kmax; ++k)
{
if (has_attribute (decls[k], decl_attrs[k], blacklist[i]))
- break;
-
- if (!k && kmax > 1)
- continue;
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
if (nattrs)
pp_string (attrstr, ", ");
pp_begin_quote (attrstr, pp_show_color (global_dc->printer));
@@ -1947,6 +1951,8 @@ decls_mismatched_attributes (tree tmpl, tree decl, tree attrlist,
pp_end_quote (attrstr, pp_show_color (global_dc->printer));
++nattrs;
}
+
+ break;
}
}