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 01CE23858002 for ; Fri, 2 Dec 2022 19:42:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 01CE23858002 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=1670010153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VNu0RgvXpbRoaCbWhtFrAtbCgEbZdPDC3+d80cZwBKs=; b=LMUtfFDTXXux0RJc0yLz/Rssk2bmNGkZyf60Qu80WEZmoIbUVgN8gTvvT7GUfP18XNKZrK hvj+UteSyfiDE0elM8diolGq9V4G4kD9QPsdjfZq7VSQ3uAIE1ABVA80VzbN2nsJTDmaSA dUfytBjvh5uLNPDpaARZe4LpSfUaAfw= 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-118-86Mt8VajOFCIP3-jXH8Jvw-1; Fri, 02 Dec 2022 14:42:32 -0500 X-MC-Unique: 86Mt8VajOFCIP3-jXH8Jvw-1 Received: by mail-qt1-f198.google.com with SMTP id k1-20020ac84781000000b003a6894cdd5eso20886375qtq.14 for ; Fri, 02 Dec 2022 11:42:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VNu0RgvXpbRoaCbWhtFrAtbCgEbZdPDC3+d80cZwBKs=; b=e4WJ7GGV4npwq9wLBmR8zUjvjsO04x/xPMpr4m9xow1wKw/QqwY2UhuPcJsEmFc3Gz Vq2R77qcR5Mscl1lMpDpx9fVmqecnTgoiB7HMIGBi0zL+x2TXkVlBuXx6fQsvwPfHoI9 drA0YW7RG+1R5FOwXE6Et+fMhOEfpEox252qKqjNF8V7SWqAEHPJfrgqDhmT3u50/AF4 HcwCQGOhyuniYZNl4ZseTykHFYSbZTzbs0koRrGPm3v9ip0gSbDimA5c0TGTftqDoOrG Z749cl9Rj/7dyhluZOznkB2S/MAWUblECod1aoJCiFa5EwVEH8nqR28r3A3zuddC4vqk 9iCg== X-Gm-Message-State: ANoB5pljd5d87PwjpzzVj1GBxxnPWEKBofg8a9wtETeKQBrfI4q8iYmt eCKuuN6AdlqiZl2LwTeo0u8heFybvMIFEZqawPnCle0gfPL1KMEbjqceZV5QW0El9QVSiL52utP XaTb9HPzG3Zl7C0OBdkQX01iN3L/bHES2DTFnMOZlXK8vM0e+WfhxmSOeJsX4wjAHjZI= X-Received: by 2002:ac8:5406:0:b0:3a6:8ef8:6a13 with SMTP id b6-20020ac85406000000b003a68ef86a13mr11034549qtq.563.1670010151542; Fri, 02 Dec 2022 11:42:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XDpuLM5+1EimduTdcg/KbqyjJ7CUze66tvtau/Spt/SkTpiQjFVlSEvJp8SqPrmowWYkISw== X-Received: by 2002:ac8:5406:0:b0:3a6:8ef8:6a13 with SMTP id b6-20020ac85406000000b003a68ef86a13mr11034530qtq.563.1670010151202; Fri, 02 Dec 2022 11:42:31 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id l11-20020a05620a28cb00b006f9e103260dsm6535647qkp.91.2022.12.02.11.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 11:42:30 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: unexpanded pack in requires-expr parm list [PR107417] Date: Fri, 2 Dec 2022 14:42:28 -0500 Message-Id: <20221202194228.3794597-1-ppalka@redhat.com> X-Mailer: git-send-email 2.39.0.rc0.49.g083e01275b 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.7 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,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: 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? 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" } +} -- 2.39.0.rc0.49.g083e01275b