From patchwork Tue Apr 26 20:11:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1622685 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=vlF9wIVZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4KntNM6Kdyz9s09 for ; Wed, 27 Apr 2022 06:12:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22D3F3857C42 for ; Tue, 26 Apr 2022 20:12:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22D3F3857C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651003966; bh=WtGBnb5M6NlgYDJaVl8rI83UubMRjkTTXd6FDUltbks=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vlF9wIVZzmcmvcKmhT03jhg+1W1V4E8aLdwRYAx5zgPBRhwqV6qYqYEghQIO31Uz3 VBRAduyDoQq4MgT3rnxRZiq8I1+m2OkjTglWeobHc+CGwtHvHS6Cj0/LT++9DKYmrQ bZEPztjnB5JmZb1G/wyRbVT+/5VuE9bRXUqM3hJA= 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 9376B3858C83 for ; Tue, 26 Apr 2022 20:12:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9376B3858C83 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-9OdmqqLNMdK4C8gfo8HHjQ-1; Tue, 26 Apr 2022 16:12:02 -0400 X-MC-Unique: 9OdmqqLNMdK4C8gfo8HHjQ-1 Received: by mail-qv1-f69.google.com with SMTP id kj4-20020a056214528400b0044399a9bb4cso15654248qvb.15 for ; Tue, 26 Apr 2022 13:12:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=WtGBnb5M6NlgYDJaVl8rI83UubMRjkTTXd6FDUltbks=; b=3gWRRch6ELhtC7bd13MqAk2QxCOdcdonCt2LTcKQqJS5bFDBv+VXF53mPHTwevWtm0 VwO3fgDOiyO9jwgnqc1/TAjMOh9xwnlEfE7ZX6H/f1lCJrMIUmpC2hBOBiztk2ybT3I9 gHpMs6q1vKHt/epRlOawNF/8jWBRAUTJ+W+HIJhJfkLmtyhWq+Z01q9jGKNkFMpnZlNe LbVA5GGaWyXj5KX6tLa5R8thcWMQZwdrLnlBIKVLqvdgEY8LuQqWzLKVIJWzv/DVNY99 tf61kbF8rZTardLCjjYbF0AleVDuptomARgrPBcGEOfRZx73OXdTjcd4/6SIhkdav4Os BlIg== X-Gm-Message-State: AOAM531UXxY5Y36MLJ+R+J4e4zgEXRLT1jEMI0jtu+G+Serk3ZfB79se HjyG3MzJWajbCCwTcvCtSAifocn1+8UnBaNDw5S/IZYhFSga0D7HC5p+uCrIYkucrNfXlWYOdc5 RARNy4yojzWkI+LbPzCSZvdJVYyv1XMi9ikZLBfG4jStzqEgb8ECUHoa9gKhudEdq9g== X-Received: by 2002:ad4:5f06:0:b0:446:e96:b193 with SMTP id fo6-20020ad45f06000000b004460e96b193mr17372858qvb.100.1651003921635; Tue, 26 Apr 2022 13:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqiwtsH5sp5KKfDRyN7JYTPYd+ampqgAHIuFFsa0Sqm8qZUQlEA6/0mFDG1AeUwGUUgEYx5w== X-Received: by 2002:ad4:5f06:0:b0:446:e96:b193 with SMTP id fo6-20020ad45f06000000b004460e96b193mr17372843qvb.100.1651003921235; Tue, 26 Apr 2022 13:12:01 -0700 (PDT) Received: from barrymore.redhat.com (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 d1-20020a05622a15c100b002f373d233d3sm2346057qty.71.2022.04.26.13.12.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 13:12:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: pack init-capture of unresolved overload [PR102629] Date: Tue, 26 Apr 2022 16:11:59 -0400 Message-Id: <20220426201159.680184-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Here we were failing to diagnose that the initializer for the capture pack is an unresolved overload. It turns out that the reason we didn't recognize the deduction failure in do_auto_deduction was that the individual 'auto' in the expansion of the capture pack was still marked as a parameter pack, so we were deducing it to an empty pack instead of failing. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102629 gcc/cp/ChangeLog: * pt.cc (gen_elem_of_pack_expansion_instantiation): Clear TEMPLATE_TYPE_PARAMETER_PACK on auto. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-pack-init7.C: New test. --- gcc/cp/pt.cc | 8 +++++++- gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C base-commit: 7d31c678d68d7b6820a958584619ca763b0eb9c5 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index a77b3166818..3cf1d7af8d2 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12682,7 +12682,13 @@ gen_elem_of_pack_expansion_instantiation (tree pattern, t = tsubst_expr (pattern, args, complain, in_decl, /*integral_constant_expression_p=*/false); else - t = tsubst (pattern, args, complain, in_decl); + { + t = tsubst (pattern, args, complain, in_decl); + if (is_auto (t) && !ith_elem_is_expansion) + /* When expanding the fake auto... pack expansion from add_capture, we + need to mark that the expansion is no longer a pack. */ + TEMPLATE_TYPE_PARAMETER_PACK (t) = false; + } /* If the Ith argument pack element is a pack expansion, then the Ith element resulting from the substituting is going to diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C new file mode 100644 index 00000000000..f3c3899e97a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C @@ -0,0 +1,18 @@ +// PR c++/102629 +// { dg-do compile { target c++20 } } + +template T&& forward(T&); +template T&& forward(T&&); + +struct S {}; + +template +void foo(Args&&... args) { + [...args = forward /*(args)*/] { // { dg-error "" } + [](auto...) { } (forward(args)...); + }; +} + +void bar( ) { + foo(S{}); +}