aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-12-17 14:34:12 -0500
committerMarek Polacek <polacek@redhat.com>2022-01-03 15:53:59 -0500
commitbb936163e28fdbe1a751c55d5e5975e036322a3d (patch)
tree130cb9bfa92774db356aa2b16618942b37a4302d /gcc/c-family
parent1096ab1775636f35de9c6661f8f71f03299af998 (diff)
downloadgcc-bb936163e28fdbe1a751c55d5e5975e036322a3d.zip
gcc-bb936163e28fdbe1a751c55d5e5975e036322a3d.tar.gz
gcc-bb936163e28fdbe1a751c55d5e5975e036322a3d.tar.bz2
c-family: Have -Wformat-diag accept "decl-specifier" [PR103758]
I'm tired of seeing cp/parser.c:15923:55: warning: misspelled term 'decl' in format; use 'declaration' instead [-Wformat-diag] cp/parser.c:15925:57: warning: misspelled term 'decl' in format; use 'declaration' instead [-Wformat-diag] every time I compile cp/parser.c, which happens...a lot. I'd like my compilation to be free of warnings, otherwise I'm going to miss some important ones. "decl-specifiers" is a C++ grammar term; it is not actual code, so should not be wrapped with %< %>. I hope we can accept it as an exception in check_tokens. It was surrounded by %< %> in cp_parser_decl_specifier_seq, so fix that. In passing, fix a misspelling in missspellings. PR c++/103758 gcc/c-family/ChangeLog: * c-format.c (check_tokens): Accept "decl-specifier*". gcc/cp/ChangeLog: * parser.c (cp_parser_decl_specifier_seq): Replace %<decl-specifier%> with %qD. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-condition.C: Adjust dg-error.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-format.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 7d3b311..afa7781 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -3194,7 +3194,7 @@ check_tokens (const token_t *tokens, unsigned ntoks,
wlen, format_chars);
else
{
- /* Diagnose some common missspellings. */
+ /* Diagnose some common misspellings. */
for (unsigned i = 0; i != sizeof badwords / sizeof *badwords; ++i)
{
unsigned badwlen = strspn (badwords[i].name, " -");
@@ -3215,6 +3215,12 @@ 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. */
+ if (badwords[i].name[0] == 'd'
+ && startswith (format_chars, "decl-specifier"))
+ continue;
+
format_warning_substr (format_string_loc, format_string_cst,
fmtchrpos, fmtchrpos + badwords[i].len,
opt,