From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F03B1385AC19 for ; Fri, 1 Jul 2022 14:53:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F03B1385AC19 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-154-0rVoVX4sO3ehUzW6koPHuQ-1; Fri, 01 Jul 2022 10:53:31 -0400 X-MC-Unique: 0rVoVX4sO3ehUzW6koPHuQ-1 Received: by mail-qv1-f70.google.com with SMTP id m7-20020ad45dc7000000b0047042480dbfso2702555qvh.9 for ; Fri, 01 Jul 2022 07:53:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=bm1kCsch9DFUK2gJ/SFb8E6l3a7kSZf9lFYNPbJxlW8=; b=Mwg42BjMuvWP3bzpcCz9BBVa0liAlkR1gWxqzeiQpTG6XbzPZTqUBy81nGSXauCiFP 8TR45icVHRHDT9LWscD4FUnVmiA2rY9+LLIaWMOO4j2pA287fsYNQ/M8J13S/ybInKFh gRv74IlVFm4/ACWmt+JIUY6I1k3rqOgXmST1Bcnq2QskW9/FulaLdHeJsuqHaYPKpEhH eUlTzeOX0NC7s5Zg73zHstAq2y6AdzFG2/PxittXJZwwwHIzcKMVGzv2RossWuKOBnSs eAPmziGYEOIj/Rb161A/sPcSN2XKCjqFuTVbcOpamdQVTRbDqGn5sCDfKRiFj4TIFFUI Gh5w== X-Gm-Message-State: AJIora+8cKRqC74/LfhfifhfUHPiBcWwzuL5+zkWDlKzL2PyyHoj1zMl p9viuNocIq+di/NnWtRmh3jSZMm+mKHqotR1wJ3T4KWNUqO9oGbXCmu88QuwNPch1xsrYGLb5Ti gItWMSYL8dt0GrVDv07I382Sg5SRXeynNaC7ath5zZfw3ocjQJPaVQ0wb9OmeBoQ0kw== X-Received: by 2002:ad4:5f0c:0:b0:470:3f36:6baa with SMTP id fo12-20020ad45f0c000000b004703f366baamr16548149qvb.119.1656687210899; Fri, 01 Jul 2022 07:53:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tpPJVfpRalgjXHWlD9cr8nYIuynY0vO8ogBJa2KpRsJt6xYM+0NFxR0cqD1HPiEkUqN8GkOg== X-Received: by 2002:ad4:5f0c:0:b0:470:3f36:6baa with SMTP id fo12-20020ad45f0c000000b004703f366baamr16548117qvb.119.1656687210499; Fri, 01 Jul 2022 07:53:30 -0700 (PDT) Received: from barrymore.cygnus.csb (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id n8-20020a05620a222800b006ab935c1563sm16761865qkh.8.2022.07.01.07.53.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 07:53:30 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: add fixup to missing .template warning Date: Fri, 1 Jul 2022 10:53:28 -0400 Message-Id: <20220701145328.907669-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jul 2022 14:53:34 -0000 I experimented with giving this diagnostic in another place, which didn't work out, but we can still benefit from adding the fixup. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * parser.cc (missing_template_diag): Split out... (cp_parser_id_expression): ...from here. --- 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; base-commit: 07ac550393d00fcadcee21b44abee6bb30c93949 -- 2.27.0