public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marek Polacek <mpolacek@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9474] c-family: Have -Wformat-diag accept "decl-specifier" [PR103758] Date: Mon, 17 Jan 2022 21:27:02 +0000 (GMT) [thread overview] Message-ID: <20220117212702.2F08E385801C@sourceware.org> (raw) https://gcc.gnu.org/g:2c4b5bd4440292eca51de1f09ccce0d139ab981e commit r11-9474-g2c4b5bd4440292eca51de1f09ccce0d139ab981e Author: Marek Polacek <polacek@redhat.com> Date: Mon Jan 17 16:26:01 2022 -0500 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. (cherry picked from commit bb936163e28fdbe1a751c55d5e5975e036322a3d) Diff: --- gcc/c-family/c-format.c | 9 ++++++++- gcc/cp/parser.c | 2 +- gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 0a63cacb0d9..f4359657fc1 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -3202,7 +3202,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, " -"); @@ -3223,6 +3223,13 @@ 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' + && strncmp (format_chars, "decl-specifier", + strlen ("decl-specifier")) == 0) + continue; + format_warning_substr (format_string_loc, format_string_cst, fmtchrpos, fmtchrpos + badwords[i].len, opt, diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 01006989a02..d1b671e77c9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15054,7 +15054,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, if (found_decl_spec && (flags & CP_PARSER_FLAGS_ONLY_TYPE_OR_CONSTEXPR) && token->keyword != RID_CONSTEXPR) - error ("%<decl-specifier%> invalid in condition"); + error ("%qD invalid in condition", ridpointers[token->keyword]); if (found_decl_spec && (flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C index 733d494c4d7..e81acba68ae 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C @@ -5,5 +5,5 @@ constexpr int something() { return 3; } int main() { if (constexpr long v = something()) {} - if (static long v = something()) { } // { dg-error "'decl-specifier' invalid" } + if (static long v = something()) { } // { dg-error "'static' invalid" } }
reply other threads:[~2022-01-17 21:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220117212702.2F08E385801C@sourceware.org \ --to=mpolacek@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).