On Mon, Dec 20, 2021 at 03:21:04PM -0500, Jason Merrill via Gcc-patches wrote: > > @@ -3215,6 +3215,14 @@ check_tokens (const token_t *tokens, unsigned ntoks, > > plural = "s"; > > } > > + /* As an exception, don't warn about "decl-specifier*" since > > + it's a C++ grammar production. */ > > + { > > + const size_t l = strlen ("decl-specifier"); > > + if (!strncmp (format_chars, "decl-specifier", l)) > > + return format_chars + l - 1; > > + } > > I'd prefer to avoid repeating the string literal, but OK.
We have the startswith inline function that allows to avoid the repetition. It wouldn't work in the above case due to the return format_chars + l - 1, but that in itself looks quite weird to me, I'd think better would be continue; instead of the return ...;, i.e. whenever we see decl-specifier in the text pretend we haven't seen decl. So /* As an exception, don't warn about "decl-specifier*" since it's a C++ grammar production. */ if (startswith (format_chars, "decl-specifier")) continue; ? Or perhaps even optimize and don't compare uselessly everything with "decl-specifier" and do it only for the "decl" badword if it matches, so if (badwords[i].name[0] == 'd' && startswith (format_chars, "decl-specifier")) continue; ? Jakub