From patchwork Mon Feb 5 21:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 197028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1157668dyb; Mon, 5 Feb 2024 13:34:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/yxMd7E6FWn0olOljP0JRT29GGjldVW9MJIxuuYcvmB44LlQZA7gI+DHBYa1XKd3c9aso X-Received: by 2002:ae9:f409:0:b0:785:5f32:740 with SMTP id y9-20020ae9f409000000b007855f320740mr636036qkl.39.1707168863391; Mon, 05 Feb 2024 13:34:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168863; cv=pass; d=google.com; s=arc-20160816; b=ObD4djDSSMnpBMsWmAOTsSqESYloZf5d+SuzvJgxFhE2XkJkeoMOU/f3UbzR3JPEBT L/QnLlo8YxeVTCj45X56CNXBLZYLbDqTxV7vVjKOCk23EScAllW2x+kYG5s+Pau3XqhW pZ7uXU5/JZ0TdFg78xvmTdMrYOueTYqt4JXeLVsCyiq22vTIrNxaE5bZrczdS0bo8uSo TdUti+7KsqQGj3Wl6FYIjgmnoryPPQmcQnjZOut8/shipsAFBPPpqWkD3vl0JSVjMgEi /kUKkko0ggE6xVdZ2RxGkbauhSYnfYQEe9gc3uSFQLY0CY3I3DBN8uIUv0R+0RZqnauV oQYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ukjtw8k+9oDfhjx851RuP09bj+EekyqxVjcuvPHzxA0=; fh=leydiePwV7a+Sch2+xjtWXRAlSBqd+f4e75SDmRzDNY=; b=c0nC2AF0xIIQ+doLqCIU3UseYXYBivCm1youfJaCV422rEV0Y8btpinU4V28U9Xv/4 eSrqH3Yd7vDyMmx2NMDQdf+e9NlGgheV9jGr+t3D7/oJNzXZEdQhV1WIeYS8kLIiYmt+ E014UUef2Q0ggUm2zoBRpPOvdN5NsvdTbtHFbR9H0vErGXfcFEpiysUfu1k7RKw6knTW jinuka1+oT03WWrX6Li741C4+qr+yUSpwcQWiobnJGm0kWo+haBBOvyfkN2hQ/lAr4IG pdVECPfONj8dGiqQRc5wpddmV1F4+Vpd7kv1CCBuNQmShU6dV/xSZES7hM30Il14U5DJ ysew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="b/tSbdsM"; arc=pass (i=1); 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=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVXIpB0NacJMPLRNUdE3LgkhE1r0qP/bTkI5pNSQQyCbIDI7mISymxV4ukg696trv2TTcPj4fo7V0MTg4O7EAKMB6hdNg== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bj16-20020a05620a191000b007858ab280a7si798940qkb.152.2024.02.05.13.34.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:34:23 -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=@redhat.com header.s=mimecast20190719 header.b="b/tSbdsM"; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18C3E385842D for ; Mon, 5 Feb 2024 21:34:23 +0000 (GMT) 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 928FF3858C2D for ; Mon, 5 Feb 2024 21:33:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 928FF3858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 928FF3858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707168809; cv=none; b=k3OCZFGSdVmmUkMbHsQ7mygKd2xvn/8JbciIL/2BVK97c/Pu+Iw4ZfIsTr/9I88q5V33k50bi2SwKwAlGkXVfjF1fOC2DN4ftmrr8ne3TdCngDJtI/4+djWEdMaFuuslS0Cihp26noY82pNx9/pNaEta+6dW0XnVqcatBY4/AJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707168809; c=relaxed/simple; bh=u8W+yUf/25einf4KyR9ltIXDo+Za7WZSdqavaCed29s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=esmJhjJYBBn1NIjRL3tszuqS64gbT8+DYNLZK85zcnMTtUc55f2e1maxWzYRYx+N6mv60zYmRkwevbbaLzalXcZ5+TmJF+du9Zu5SQRh3FrVIZf0OC8CsSr43q29VoEofyBnDT7fsiTqbj5lNrtc4P3xc8KVtVFDiuhZifCDfrk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707168807; 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; bh=ukjtw8k+9oDfhjx851RuP09bj+EekyqxVjcuvPHzxA0=; b=b/tSbdsM1W3s1wnLTtnJb2DPS5+yW2G8+MS4sEwD9gdIIzHdSigSj6xzLFy5d5YzA5vkU4 f0IuJxen60K0BBJFNDBIw89s8kf2TxNp77D9GfLnwFA7sqguFZtrpPeu2Z6tu9PBC7Mc+z f0CTQl2e2JZeoLXoEpkqOHZpHrUu1c4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-YNcauzQUMQq5jQXMGuhT6g-1; Mon, 05 Feb 2024 16:33:25 -0500 X-MC-Unique: YNcauzQUMQq5jQXMGuhT6g-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-68c4f4dea85so71993806d6.1 for ; Mon, 05 Feb 2024 13:33:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707168805; x=1707773605; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ukjtw8k+9oDfhjx851RuP09bj+EekyqxVjcuvPHzxA0=; b=oYgqbAnvBTHRaEDuGAv0scvz7OMQFlpVtB1789Y0Lk5FlOrkOYNTywUcG58l81kHVW +7ZkUatpETczChKfuo1Fo7S688v/+/GWqACffBbfc4b0tQnsjasLqEg9PqPEuDovyfuS nqsd5aCujOH6PVpp6lwIXm+ou2k+7yez6ijECgkZe63f8Qw9TkFzt67s1OuI9mWZDYKm gQnJL7SBPN9yCkM5zK3YK2BnlEIjoEWfyDi4rx7JbcB1xNDfol1rwhcLliAFnBZ6DN5O WyDKroknj01rsSXN3lJL7PLpLDQxjtrDMDX9e2izJWTrKLP2JUEA1+X7ci4BVpkjHwmi cNBw== X-Gm-Message-State: AOJu0YykgOZvLF600VIVUZG2+FCXYOGh6eDILRnzUDDJhH7VJ9heS47b GDSBWSxyYtGfvYAAvKjCmYkKT+7tEzdJDFGM/qxEqooo44J2ACJWbaV94PmY6nidX4/J+0iOHb5 /7ypiyWHlMBhFKOcv3kKkmBlXAXcSBEhDWlh3GSYl+Ss807gusz0+WuiAD71sRFKfcbNJkzcRaa UHdOQXsGUrhnDVO6/PiVdS/klbR3+fchgDZH4= X-Received: by 2002:ae9:f807:0:b0:783:2a08:8044 with SMTP id x7-20020ae9f807000000b007832a088044mr599959qkh.57.1707168805066; Mon, 05 Feb 2024 13:33:25 -0800 (PST) X-Received: by 2002:ae9:f807:0:b0:783:2a08:8044 with SMTP id x7-20020ae9f807000000b007832a088044mr599942qkh.57.1707168804570; Mon, 05 Feb 2024 13:33:24 -0800 (PST) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id g24-20020ae9e118000000b0078536f14c08sm315527qkm.47.2024.02.05.13.33.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:33:24 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: prvalue of array type [PR111286] Date: Mon, 5 Feb 2024 16:32:16 -0500 Message-ID: <20240205213322.820275-1-jason@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790096298200107125 X-GMAIL-MSGID: 1790096298200107125 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Here we want to build a prvalue array to bind to the T reference, but we were wrongly trying to strip cv-quals from the array prvalue, which should be treated the same as a class prvalue. PR c++/111286 gcc/cp/ChangeLog: * tree.cc (rvalue): Don't drop cv-quals from an array. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-array22.C: New test. --- gcc/cp/tree.cc | 9 +++++---- gcc/testsuite/g++.dg/cpp0x/initlist-array22.C | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-array22.C base-commit: f1412546ac8999b7f6eeeee8cf967ce3f31794c2 diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 5c8c05dc168..50dc345ec9a 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -977,11 +977,12 @@ rvalue (tree expr) expr = mark_rvalue_use (expr); - /* [basic.lval] - - Non-class rvalues always have cv-unqualified types. */ + /* [expr.type]: "If a prvalue initially has the type "cv T", where T is a + cv-unqualified non-class, non-array type, the type of the expression is + adjusted to T prior to any further analysis. */ type = TREE_TYPE (expr); - if (!CLASS_TYPE_P (type) && cv_qualified_p (type)) + if (!CLASS_TYPE_P (type) && TREE_CODE (type) != ARRAY_TYPE + && cv_qualified_p (type)) type = cv_unqualified (type); /* We need to do this for rvalue refs as well to get the right answer diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array22.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array22.C new file mode 100644 index 00000000000..8629e4be239 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array22.C @@ -0,0 +1,12 @@ +// PR c++/111286 +// { dg-do compile { target c++11 } } +// { dg-additional-options -Wno-unused } + +struct A { + A() noexcept {} +}; + +void foo() { + using T = const A (&)[1]; + T{}; +}