From patchwork Tue Mar 29 08:05:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1610532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=vheAmmqB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KSMZR36N4z9sBy for ; Tue, 29 Mar 2022 19:05:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 03528389942B for ; Tue, 29 Mar 2022 08:05:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03528389942B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648541148; bh=9EffQEETfRGz0lVkKTLnpstTQtSkVX+DiWvbOQPYJ0I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=vheAmmqBE9/Ifle/UkZ6ARbtQAaxO6J+fBWe8nq1619aqsN8St4YFuTLHPMa9AIa3 gQQEiOUjwmqDtJlepFuDIVnzofZ8cbVvGbCZoX+921sRrcNmjeTzUPV5jDeVbaAmVg nPzWB94smp2PbTLOBgSGu0SFa6m46prXRqAnbuPo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B0B5C3888829 for ; Tue, 29 Mar 2022 08:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0B5C3888829 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-LgWnSGNjP7mnQGpzdhFP0Q-1; Tue, 29 Mar 2022 04:05:23 -0400 X-MC-Unique: LgWnSGNjP7mnQGpzdhFP0Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46D37185A7BA for ; Tue, 29 Mar 2022 08:05:23 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02AE540CF905; Tue, 29 Mar 2022 08:05:22 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 22T85Kd12569545 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 29 Mar 2022 10:05:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22T85KPN2569544; Tue, 29 Mar 2022 10:05:20 +0200 Date: Tue, 29 Mar 2022 10:05:20 +0200 To: Jason Merrill Subject: [PATCH] c++: Fox template-introduction tentative parsing in class bodies clear colon_corrects_to_scope_p [PR105061] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The concepts support (in particular template introductions from concepts TS) broke the following testcase, valid unnamed bitfields with dependent types (or even just typedefs) were diagnosed as typos (: instead of correct ::) in template introduction during their tentative parsing. The following patch fixes that by not doing this : to :: correction when member_p is true. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and release branches (so far also bootstrapped/regtested on the above targets on 11 branch)? 2022-03-29 Jakub Jelinek PR c++/105061 * parser.cc (cp_parser_template_introduction): If member_p, temporarily clear parser->colon_corrects_to_scope_p around tentative parsing of nested name specifier. * g++.dg/concepts/pr105061.C: New test. Jakub --- gcc/cp/parser.cc.jj 2022-03-26 08:11:50.030217910 +0100 +++ gcc/cp/parser.cc 2022-03-28 17:30:41.488053848 +0200 @@ -31417,9 +31417,15 @@ cp_parser_template_introduction (cp_pars tree saved_scope = parser->scope; tree saved_object_scope = parser->object_scope; tree saved_qualifying_scope = parser->qualifying_scope; + bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p; cp_token *start_token = cp_lexer_peek_token (parser->lexer); + /* In classes don't parse valid unnamed bitfields as invalid + template introductions. */ + if (member_p) + parser->colon_corrects_to_scope_p = false; + /* Look for the optional `::' operator. */ cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); @@ -31440,6 +31446,7 @@ cp_parser_template_introduction (cp_pars parser->scope = saved_scope; parser->object_scope = saved_object_scope; parser->qualifying_scope = saved_qualifying_scope; + parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p; if (concept_name == error_mark_node || (seen_error () && !concept_definition_p (tmpl_decl))) --- gcc/testsuite/g++.dg/concepts/pr105061.C.jj 2022-03-28 17:34:02.051207207 +0200 +++ gcc/testsuite/g++.dg/concepts/pr105061.C 2022-03-28 17:33:14.502882074 +0200 @@ -0,0 +1,13 @@ +// PR c++/105061 + +template +struct A { T : V, u : U; }; +template +struct B { unsigned : V, u : U; }; +typedef unsigned uns; +template +struct C { uns : V, u : U; }; + +A a = { 13 }; +B<5, 6> b = { 26 }; +C<8, 9> c = { 42 };