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 5EFA3385060D for ; Thu, 15 Dec 2022 16:59:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5EFA3385060D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671123580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YVgIy2OEKh8k6kXS+bK7Amm3s5IovHah14nn168XcdI=; b=ORTV/ypuCHADQnvPAkZGNP75AV8mKHa8nRu7GZs+OxikoAvyjGMuNIhsBkyqTt0xLi65kL TCeE8FlDiVm864D5/F5EZDXNACq5bOehBxrq/wVS+Ac8TAax6vnZwKPqCrcYTpxE4z5/uY jNupt1Uf6VRXgMM5eBIwL3Qakhwg7RY= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-668-2WEyNaF0NouXDTvuMT0Wxg-1; Thu, 15 Dec 2022 11:59:38 -0500 X-MC-Unique: 2WEyNaF0NouXDTvuMT0Wxg-1 Received: by mail-qt1-f198.google.com with SMTP id o9-20020ac841c9000000b003a820e4c248so14273qtm.2 for ; Thu, 15 Dec 2022 08:59:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YVgIy2OEKh8k6kXS+bK7Amm3s5IovHah14nn168XcdI=; b=v0/D8xKDyaPPkiIMzK27RcmlsMYQNS/mFrwAHLB4JRducS5y91l6Mr9IEXZoypmFQ9 BF11ru6E6419WXksPK0ye8l8atlIqzzNVchTsiHZeKGLGQUZ3B2jjJJBb7JDBPru5XGp emTBJke4FY/FqMMSXlJUVFUbeKuBbzgnaTP6WqGm/L/8k/aOgIMegwZajsngU7h+y80S TvWBQ9qS4zkD1ajPstrJ+RwBPmFsPveyqRsvAzqLIlg5fopo67BV/EYLS1wraEoys9Dn JaushZQr6p0znX9vsj0Ig6PejSLt773HZI35liHSxeNi67t7cRdoGhNfEoC6k4ESpplv 1LSA== X-Gm-Message-State: ANoB5pmO/P5KjgIDvZ35WTj9zKEicalZYS4Gp/vqoSaaDhZpioeALdxd fbFmjLBdCx6aEalpL3qEfVM8QxXrcHW9T2oEdgZxOvTgVlE44z/qto87mzobUnNu4QwvNCCo5hI daKu4T67cMruoDAEz8Q== X-Received: by 2002:ac8:71cf:0:b0:3a8:104c:11cd with SMTP id i15-20020ac871cf000000b003a8104c11cdmr29929185qtp.35.1671123578177; Thu, 15 Dec 2022 08:59:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xb+x9C/Rt67/6Kn6ZoasbByYAuW0i571kjIBbjvI9s4xs5Emc6tqILgq2WmqLT4djy820EA== X-Received: by 2002:ac8:71cf:0:b0:3a8:104c:11cd with SMTP id i15-20020ac871cf000000b003a8104c11cdmr29929154qtp.35.1671123577829; Thu, 15 Dec 2022 08:59:37 -0800 (PST) Received: from [192.168.1.108] (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 a25-20020ac87219000000b003995f6513b9sm3666993qtp.95.2022.12.15.08.59.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 08:59:37 -0800 (PST) Message-ID: <7cfc86a7-43f6-7774-7612-9997dc3a329c@redhat.com> Date: Thu, 15 Dec 2022 11:59:36 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] c++: class-scope qualified constrained auto [PR107188] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20221208164230.2208644-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20221208164230.2208644-1-ppalka@redhat.com> 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: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/8/22 11:42, Patrick Palka wrote: > Here when parsing the class-scope auto constrained by a qualified > concept-id, we first tentatively parse the overall member-declaration as > a deprecated access-declaration, during which we parse C as a > standalone TEMPLATE_ID_EXPR (not part of the auto) and end up emitting > the bogus error > > concepts-placeholder11.C:9:6: error: wrong number of template arguments (1, should be 2) > 9 | N::C auto f() { return 0; } > | ^~~~~~ > concepts-placeholder11.C:5:34: note: provided for ‘template concept N::C’ > 5 | template concept C = true; > | ^ > > from build_concept_id called from cp_parser_template_id_expr. > > We could fix this by adding a complain parameter to build_concept_id and > passing tf_none when parsing tentatively. However, it seems we can fix > this in a more general way that might benefit non-concepts code: when > tentatively parsing an access-declaration, abort the parse early if the > qualifying scope isn't possibly a class type, so that we avoid parsing > C as a TEMPLATE_ID_EXPR in the first place. This patch takes this > latter approach. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > PR c++/107188 > > gcc/cp/ChangeLog: > > * parser.cc (cp_parser_using_declaration): Abort the tentative > parse early if the scope of an access-declaration isn't possibly > a class type. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-placeholder11.C: New test. > --- > gcc/cp/parser.cc | 5 +++++ > gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C | 10 ++++++++++ > 2 files changed, 15 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C > > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc > index e8a50904243..ccacf6d7dd0 100644 > --- a/gcc/cp/parser.cc > +++ b/gcc/cp/parser.cc > @@ -21670,6 +21670,11 @@ cp_parser_using_declaration (cp_parser* parser, > > cp_warn_deprecated_use_scopes (qscope); > > + if (access_declaration_p && !MAYBE_CLASS_TYPE_P (qscope)) > + /* If the qualifying scope of an access-declaration isn't possibly > + a class type then it must be invalid. */ > + cp_parser_simulate_error (parser); > + > if (access_declaration_p && cp_parser_error_occurred (parser)) > /* Something has already gone wrong; there's no need to parse > further. Since an error has occurred, the return value of > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C > new file mode 100644 > index 00000000000..61eef743bae > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C > @@ -0,0 +1,10 @@ > +// PR c++/107188 > +// { dg-do compile { target c++20 } } > + > +namespace N { > + template concept C = true; > +} > + > +struct X { > + N::C auto f() { return 0; } > +};