From patchwork Sat Nov 12 11:23:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 19166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1224340wru; Sat, 12 Nov 2022 03:24:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vQxgyqfywOuzX5GEGN9lbOfdxEadw6twYRbZ38nHaPIJKKAYeaX6ONVYZR0Ji4RsR/88b X-Received: by 2002:a17:906:e245:b0:78d:bc9f:33da with SMTP id gq5-20020a170906e24500b0078dbc9f33damr4837598ejb.80.1668252287590; Sat, 12 Nov 2022 03:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668252287; cv=none; d=google.com; s=arc-20160816; b=OGZyZ81jU4sHlRfbDtm4s8Qd91Twb17JCR7WuH7rN1/SyEtlW74Jb6XsRayl50O+iJ RtaX9d0trLuwoH/uW1CZkH1BiJDRy+wwCI90GWo5D4yCi5xlqebpw4MaOVSL4t50HKV1 TUSmw5RFQZoT+uYiIWPIvv8OI6ReaYitLEzZd6XLxwIqrF2ptOzS6rsXTeyPMIltlSv3 WeCtuaNzI5Ye2a7WN9fpMwjeYTbFE9mAztgWryaQQRLz8fhLVTUsmFxUlLzEB/5ZJvkJ 97rja3gneiMecyPtoLh4Aw81XfQ7f5KWFtGhAPzEXIEhoujjG60Qx9VOiShYdYimpTB8 TExQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=t0lTG6fxypUxk3Pq9JFOPo1F9X2gtxJAcZAVysWf13w=; b=kWKUV0rzRDLj5blgyzz6kqvW/Sn1go0svXoZ53IodQU3eBBxI1T2UMn6L/tttwKntM d6ljjohFHsXbyb0atqWYp/N60M9GrmIyzeEIGcqpATuubc8Vsv/gn0mkyV1MIAYQr9uZ q3jfqeovNItTjpJ7rbyCqqa/PvXkx6R3n3dvJa4bDZnBqR1WNybf1ZuZ2aUP/+707XG7 nz964uKHprbCgIpwa9+f7g+CdoxSdW71aoerTzslOcQW71XK8ql6qR3/gHgGn3csvKP0 blnhkGMuzSUPDe63gL/N0vKG6oXIG5NknZRRS20acc1bGiv3pWq4uesmMAemAi2UMaqE Ss+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tk2qCDZW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w10-20020a056402070a00b0045cf3759408si4412942edx.49.2022.11.12.03.24.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 03:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tk2qCDZW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 669843858039 for ; Sat, 12 Nov 2022 11:24:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 669843858039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668252286; bh=t0lTG6fxypUxk3Pq9JFOPo1F9X2gtxJAcZAVysWf13w=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=tk2qCDZWQy5tjei/+mqGVTNInckIL57qI1UGhcv92d7C/XtSzItTHZUD3n4eKjSZa 3Qte2rHxYRKMWHvimrlWQivyNoK1LGEk730/S8eAemSXwbgmY3tCctykJDdEkiAX5y UuIOGQIRy01y7uMKxE3hWJuf1jqXfqijK+hixPPs= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id A5DA93858412 for ; Sat, 12 Nov 2022 11:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5DA93858412 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-HEP0nfWbPkGY9GWX2-3SXA-1; Sat, 12 Nov 2022 06:24:00 -0500 X-MC-Unique: HEP0nfWbPkGY9GWX2-3SXA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FD8D3803905 for ; Sat, 12 Nov 2022 11:24:00 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D6612166B26; Sat, 12 Nov 2022 11:24:00 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2ACBNtYZ954418 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 12 Nov 2022 12:23:56 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2ACBNt9X954417; Sat, 12 Nov 2022 12:23:55 +0100 Date: Sat, 12 Nov 2022 12:23:54 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Implement CWG2635 - Constrained structured bindings Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749289311056139534?= X-GMAIL-MSGID: =?utf-8?q?1749289311056139534?= Hi! The following patch implements CWG2635. So far tested on GXX_TESTSUITE_STDS=98,11,14,17,20,2b make check-g++ RUNTESTFLAGS="dg.exp=decomp*" ok for trunk if it passes full bootstrap/regtest and it is voted in? 2022-11-12 Jakub Jelinek * decl.cc (grokdeclarator): Implement CWG2635 - Constrained structured bindings. Diagnose constrained auto type. * g++.dg/cpp2a/decomp5.C: New test. Jakub --- gcc/cp/decl.cc.jj 2022-11-11 17:14:33.103869977 +0100 +++ gcc/cp/decl.cc 2022-11-12 12:13:52.217239729 +0100 @@ -12660,7 +12660,8 @@ grokdeclarator (const cp_declarator *dec gcc_unreachable (); } if (TREE_CODE (type) != TEMPLATE_TYPE_PARM - || TYPE_IDENTIFIER (type) != auto_identifier) + || TYPE_IDENTIFIER (type) != auto_identifier + || PLACEHOLDER_TYPE_CONSTRAINTS_INFO (type)) { if (type != error_mark_node) { --- gcc/testsuite/g++.dg/cpp2a/decomp5.C.jj 2022-11-12 12:17:21.024392082 +0100 +++ gcc/testsuite/g++.dg/cpp2a/decomp5.C 2022-11-12 12:20:00.700214521 +0100 @@ -0,0 +1,20 @@ +// CWG2635 - Constrained structured bindings +// { dg-do compile { target c++20 } } + +namespace std { + template struct tuple_size; + template struct tuple_element; +} + +struct A { + int i; + A(int x) : i(x) {} + template int& get() { return i; } +}; + +template<> struct std::tuple_size { static const int value = 2; }; +template struct std::tuple_element { using type = int; }; + +template concept C = true; +C auto [x, y] = A{1}; // { dg-error "structured binding declaration cannot have type 'auto \\\[requires ::C<, >\\\]'" } + // { dg-message "type must be cv-qualified 'auto' or reference to cv-qualified 'auto'" "" { target *-*-* } .-1 }