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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4C449385B1AC for ; Sat, 3 Dec 2022 20:24:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C449385B1AC 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=1670099042; 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=wcIORABcz+kO7Pb5nGMkMn3hfRGMFmR0hnUJ+h2c2dk=; b=ML0/nCE+sjzQkm2akbqR8MDGWqDShmFDgywImd1augM1P9Amy5cRqNm/hK/6B6VdLoJgKS EuFD7RF1ytrZAj2bZZQ9yml6Pi7mt3w9fpePbMdV5SHhgLA8Z23rS2PtC+FJ9DXLUaNgRS oqENyUW4Sh4Y08ec2i30hqTutJBdEmw= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-267-z_HKBmBwN7-czfXYNal5iw-1; Sat, 03 Dec 2022 15:24:01 -0500 X-MC-Unique: z_HKBmBwN7-czfXYNal5iw-1 Received: by mail-qv1-f71.google.com with SMTP id q17-20020a056214019100b004b1d3c9f3acso24594724qvr.0 for ; Sat, 03 Dec 2022 12:24:01 -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=wcIORABcz+kO7Pb5nGMkMn3hfRGMFmR0hnUJ+h2c2dk=; b=jxbKZEikmjLasUksBSj//FZ7HRwXtuLXEgKhvRkm0odwcvmxxtZKcpKdfnKHb7H5u6 0guhsH2pGPe+GEVsDhOYd8PMBRfFlveb0H0Kpf9UA0Y0QgV5V3kXkkU0pmLlcdlmPh2h 29v6drK1pXrwlsOzsUZqfL5uAzXH8i2vaFUnQrbj4k9GBFoSKX787JigNTQ7ADT84iP4 zRZjeCOw0swZycLRqZt9tQ/VjsYcy1d/OxWX7uae159qDz7bArkFvcuKNCUAjg8PWpDU bdrqv2NhI3N9pKPhwD1LCbJM5MBI4nUT/hx5xTLBJPPNuCg/PRTTyLCKlUYoU/wbxMJx SOkw== X-Gm-Message-State: ANoB5pmUFeyM5/SU9e7WxLjesU3mkjH0SNz4e9wfOGBwAxg6bcfSEsWM N5MhEiuaS3pTov39qwB4HT/ExiDVXRGKGyVl75s2JuAtOOX4IpVnvooaTPJvnpwJHbd9iyJGziK X6FEUZ67HSbGNHWgKOA== X-Received: by 2002:ad4:43eb:0:b0:4bb:7ad8:deae with SMTP id f11-20020ad443eb000000b004bb7ad8deaemr53682484qvu.92.1670099040601; Sat, 03 Dec 2022 12:24:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf4obBeDjvhoi589862DYSHu/D7tSpmag/BOzzV5uEWxJG3df4bxja4A09UP6LtRXg4AJ+35TA== X-Received: by 2002:ad4:43eb:0:b0:4bb:7ad8:deae with SMTP id f11-20020ad443eb000000b004bb7ad8deaemr53682471qvu.92.1670099040279; Sat, 03 Dec 2022 12:24:00 -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 h7-20020a05620a284700b006fc94f65417sm8701443qkp.40.2022.12.03.12.23.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Dec 2022 12:23:59 -0800 (PST) Message-ID: <3687d28a-48b2-0ff6-0690-a77d7c8db4bc@redhat.com> Date: Sat, 3 Dec 2022 15:23:58 -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++: unexpanded pack in requires-expr parm list [PR107417] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20221202194228.3794597-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20221202194228.3794597-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: 7bit X-Spam-Status: No, score=-12.5 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/2/22 14:42, Patrick Palka wrote: > Here find_parameter_packs_r isn't recognizing the unexpanded pack T > inside the requires-expr's parameter list ultimately because > cp_walk_trees avoids walking the parameters, for good reason: in > > requires (Ts... ts) { } > > walking 'ts' would trigger a false positive in the unexpanded pack > checker since it's, well, an unexpanded pack. But we might as well walk > the TREE_TYPE of each parameter still, which for_each_template_parm_r > already does. > > Bootstrapped and regtested on x86_64-pc-linux-gne, does this look OK for > trunk/12? OK. > PR c++/107417 > > gcc/cp/ChangeLog: > > * pt.cc (for_each_template_parm_r) : Move > walking of the TREE_TYPE of each parameter to ... > * tree.cc (cp_walk_subtrees) : ... here. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-requires33.C: New test. > --- > gcc/cp/pt.cc | 15 -------------- > gcc/cp/tree.cc | 20 ++++++++++--------- > .../g++.dg/cpp2a/concepts-requires33.C | 11 ++++++++++ > 3 files changed, 22 insertions(+), 24 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires33.C > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index bc8ea06ceae..80110da2d8a 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -10573,21 +10573,6 @@ for_each_template_parm_r (tree *tp, int *walk_subtrees, void *d) > return error_mark_node; > break; > > - case REQUIRES_EXPR: > - { > - if (!fn) > - return error_mark_node; > - > - /* Recursively walk the type of each constraint variable. */ > - tree p = TREE_OPERAND (t, 0); > - while (p) > - { > - WALK_SUBTREE (TREE_TYPE (p)); > - p = TREE_CHAIN (p); > - } > - } > - break; > - > default: > break; > } > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index 04a055d9d77..e9b6921df6a 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -5603,15 +5603,17 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, > break; > > case REQUIRES_EXPR: > - // Only recurse through the nested expression. Do not > - // walk the parameter list. Doing so causes false > - // positives in the pack expansion checker since the > - // requires parameters are introduced as pack expansions. > - ++cp_unevaluated_operand; > - result = cp_walk_tree (&REQUIRES_EXPR_REQS (*tp), func, data, pset); > - --cp_unevaluated_operand; > - *walk_subtrees_p = 0; > - break; > + { > + cp_unevaluated u; > + for (tree parm = REQUIRES_EXPR_PARMS (*tp); parm; parm = DECL_CHAIN (parm)) > + /* Walk the types of each parameter, but not the parameter itself. > + Doing so would cause false positives in the unexpanded parameter > + pack checker since a introduced parameter pack is bare. */ > + WALK_SUBTREE (TREE_TYPE (parm)); > + WALK_SUBTREE (REQUIRES_EXPR_REQS (*tp)); > + *walk_subtrees_p = 0; > + break; > + } > > case DECL_EXPR: > /* User variables should be mentioned in BIND_EXPR_VARS > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires33.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires33.C > new file mode 100644 > index 00000000000..d07ae6dee7b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires33.C > @@ -0,0 +1,11 @@ > +// PR c++/107417 > +// { dg-do compile { target c++20 } } > + > +template > +requires (requires (T x) { true; } && ...) > +void f(); > + > +int main() { > + f(); > + f(); // { dg-error "no match" } > +}