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 A5F9438515C5 for ; Tue, 29 Mar 2022 20:55:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5F9438515C5 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-22z7BX8JNbyTnsoYrtHepQ-1; Tue, 29 Mar 2022 16:55:27 -0400 X-MC-Unique: 22z7BX8JNbyTnsoYrtHepQ-1 Received: by mail-qk1-f197.google.com with SMTP id v16-20020a376110000000b0067b2749e0fbso11364293qkb.0 for ; Tue, 29 Mar 2022 13:55:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=4AKpaGulkv9L/VzBnMrQq0JbddrdFkF2rrmsb7xpY5o=; b=wHEUeLcZG07fp8/3A7q4WYUHGjGVQt6OauEUSxxX+bxYcL+MJJWejkc4Ph9IT/aVv7 puHqp/cm0s9M/1fJgU5QUmmSfR5a9MDy31BDE4bhKkveKQhOeOXYWP5WrLF6PlhTF8SE gnuUji7htCUqMgDZ/nZbilv2o6hVwBgeX7HBDPaO7clBaBuFWj+0XrcM2tdCuoc88F6c iY3qlf3bP41xxMwdO+Wmvc4vwmHiBjmZMoxUPHzozOm5Y+rHZj6coDMco9mjVbiADKCu OURx0mS2AzhdnXEPYU9RPupbJfGZfJbaxZI6940R7macb6YpTRAGFhFm0aPnubW8bxqg OfbA== X-Gm-Message-State: AOAM530NMW5EUtSoePppitixVnh4cmDqNFEaacXWtA+uKnvcsT4c5MIR Ob/0vDV/WdFttL5wIKlqbcAEJMKgEQUGHaFEb7rwwP+0DV5oZRX2mXtnlFywmYC7MRhOYwx4mRb rvFyudmh7nbxtwnCyLA== X-Received: by 2002:a05:622a:1711:b0:2e1:eb55:9f9c with SMTP id h17-20020a05622a171100b002e1eb559f9cmr29769692qtk.299.1648587326261; Tue, 29 Mar 2022 13:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDHABq0oyUsTX2HpGR8EirxuVFZEMdU0GriZcI+kLEMdWjHuOtMqfpRiJi7ilBkTNG5OESKQ== X-Received: by 2002:a05:622a:1711:b0:2e1:eb55:9f9c with SMTP id h17-20020a05622a171100b002e1eb559f9cmr29769680qtk.299.1648587325963; Tue, 29 Mar 2022 13:55:25 -0700 (PDT) Received: from [192.168.1.149] (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 d189-20020a3768c6000000b0067b248d6b3bsm10078412qkc.46.2022.03.29.13.55.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Mar 2022 13:55:25 -0700 (PDT) Message-ID: Date: Tue, 29 Mar 2022 16:55:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] c++: Fox template-introduction tentative parsing in class bodies clear colon_corrects_to_scope_p [PR105061] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, 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-List-Received-Date: Tue, 29 Mar 2022 20:55:31 -0000 On 3/29/22 04:05, Jakub Jelinek wrote: > 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)? OK. > 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. > > --- 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 }; > > Jakub >