public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1391] c++: add fixup to missing .template warning Date: Fri, 1 Jul 2022 14:53:36 +0000 (GMT) [thread overview] Message-ID: <20220701145336.A01C9385C410@sourceware.org> (raw) https://gcc.gnu.org/g:288c6cce0277e03e08b324283b6a015a70066bb7 commit r13-1391-g288c6cce0277e03e08b324283b6a015a70066bb7 Author: Jason Merrill <jason@redhat.com> Date: Wed Jun 29 17:12:09 2022 -0400 c++: add fixup to missing .template warning I experimented with giving this diagnostic in another place, which didn't work out, but we can still benefit from adding the fixup. gcc/cp/ChangeLog: * parser.cc (missing_template_diag): Split out... (cp_parser_id_expression): ...from here. Diff: --- gcc/cp/parser.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 357fde557c7..f6bc8db8581 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -6093,6 +6093,23 @@ cp_parser_primary_expression (cp_parser *parser, /*decltype*/false, idk); } +/* Complain about missing template keyword when naming a dependent + member template. */ + +static void +missing_template_diag (location_t loc, diagnostic_t diag_kind = DK_WARNING) +{ + if (warning_suppressed_at (loc, OPT_Wmissing_template_keyword)) + return; + + gcc_rich_location richloc (loc); + richloc.add_fixit_insert_before ("template"); + emit_diagnostic (diag_kind, &richloc, OPT_Wmissing_template_keyword, + "expected %qs keyword before dependent " + "template name", "template"); + suppress_warning_at (loc, OPT_Wmissing_template_keyword); +} + /* Parse an id-expression. id-expression: @@ -6268,9 +6285,7 @@ cp_parser_id_expression (cp_parser *parser, operator. */ && (cp_lexer_peek_token (parser->lexer)->type <= CPP_LAST_PUNCTUATOR)) - warning_at (token->location, OPT_Wmissing_template_keyword, - "expected %qs keyword before dependent " - "template name", "template"); + missing_template_diag (token->location); } return id;
reply other threads:[~2022-07-01 14:53 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=20220701145336.A01C9385C410@sourceware.org \ --to=jason@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).