From patchwork Wed Feb 21 09:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 204094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp934037dyc; Wed, 21 Feb 2024 01:50:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1ZpX2689cSQoX36g6p3zIR/jPlyvaV52Iq3OpO87RJHpBhbpd7mWlKZcZeoXhPgrvjsnppwP7RxNg7xR1USS1H8fl0g== X-Google-Smtp-Source: AGHT+IHWNTc3NIX/Rqntz0sjub+8ERy2C4Ujd447Tf/kgXpFMmMH2DuUjZLpurye4TjRoLN6GAUo X-Received: by 2002:a25:908:0:b0:dc6:dc58:8785 with SMTP id 8-20020a250908000000b00dc6dc588785mr15211707ybj.62.1708509049984; Wed, 21 Feb 2024 01:50:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708509049; cv=pass; d=google.com; s=arc-20160816; b=eLGArlutpYrJVF0N+1arcLwJ/lHnwUIvtGxzvcIad9L/dU7bKMxWbYqtLbi//nElA0 OSU6W62KwQCRuaERS+2ea+xdlmiIAdPfZMU51zqd3CYd9wbAbSlJAAv5tP25pSCcc5tF 99Ipb+glFvUapY23gyggS435FId+Cy44pw5U34kR8Op3EpBiMWjxDBKI5cyS+spm5JZ9 tz3OvvBhVCIkElbG1Xltb0xUIu6S3/J7vn+gY6g8kKJ6WqG6KOklq72k1Otp1OwnNULN xfbjdSYFq+rqbCH8ty1rOk3ufMCwYIRE7OUca4Pb9viyol+pLGqw99GU47x6jl4ceVFf z46A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=9NBhFqglH9iXCw+BD1pCUz6SaNW3wh0e/nUQl+MTt4s=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=ttdoOt/vQg9LRIrzHu9T0C36GFiRL3Jp+B1YQwK+mqPWqvk41F+IV9tU0PRMGehYgm Hmyblmjo0+Y/xI77OjO3bOi9wMj8z6ZxnjX4OBdVc6slcDbvVjbOj6jb/s0U5oj22gjX FNMFHplE8bRjfC/928znGmb2uJnBfAmrLkBm17BCRz21GsDokEWBXta8Odn0aUBUD2gW 85O6aOxLd/6LKY+/sGiadOTSvWtVc6ImCK5wGbR0J2FiD/frCQIogWp4SjV1UIzxVB/r HbFoZmYMww4O3++S9f0LqHsDgdgarUnSTgcCOz/P9fY4orl4dqVKuaKizTmbeAIRAAST 0m8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="F/XDonXl"; 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=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u11-20020ac858cb000000b0042e3a0ddd27si590739qta.202.2024.02.21.01.50.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:50:49 -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="F/XDonXl"; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D8543858413 for ; Wed, 21 Feb 2024 09:50:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D8543858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708509049; bh=9NBhFqglH9iXCw+BD1pCUz6SaNW3wh0e/nUQl+MTt4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F/XDonXlsArndHvnhy/0Fwl5Mm5E+89iN4wyXxyzP5DjuWkgVcLCtkb7Lt74sBBd+ jz1u3iz7wLDm2Drwzzs8xkgiE7DM9UZDwaI9yHWH3O9IFfThuAYgZVlYcPSmke3ExS LuV3iw5ROGJwKtZ9gKeNlVGUZUSy0/dLVHQWLfDA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id BE1403858C53; Wed, 21 Feb 2024 09:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE1403858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BE1403858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708508198; cv=none; b=EJIxhfzQ+8y0ECjotizut3/KqSxn5S6SdK5af/CHraFWrK6EB7lrzk9bAbhmodODmxI9GG8JMk6TdIJ4BmibUexKHIsnBNp96Pi6H7aQKp/GpvN0OZhgfTwCu5w4te53G1I2GTazdT6d21OapC+KgGh+UvQnLLvVvYoxK1OzxXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708508198; c=relaxed/simple; bh=7LL7qMrbvKzLOjtntCZaEUlku+JTEdX8VwiZwC4xLd8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NMWHl17RZT5m4CbSs5XCTOGMsefeAdhLTGnB5VNrw+/cmr8YxVCICW/ixkHWeqcGmVsHzW279JnzkjKBgg3jzJNAWFAsSHXyxRN0hHw6wY3TPZZvEP3y3ZY6eafJIagAUP9C8P20TEqYq6WO4cJvyO3MPhMlxNG6CKM4/J8Xgns= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247478.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41L9ZpC8008759; Wed, 21 Feb 2024 09:36:35 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3wd56h35sj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 09:36:35 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.132]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW24.02) with ESMTP id 41L9aKws019129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Feb 2024 01:36:20 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.128]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW24.02) with ESMTPSA id 41L9aJVd002942 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 01:36:20 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v13 13/26] c++: Implement __remove_all_extents built-in trait Date: Wed, 21 Feb 2024 01:36:03 -0800 Message-ID: <20240221093616.4001742-13-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221093616.4001742-1-kmatsui@gcc.gnu.org> References: <20240221085142.3779280-26-kmatsui@gcc.gnu.org> <20240221093616.4001742-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: LM0nRGh10tyayoLqRI3X_9qqXGu5pff3 X-Proofpoint-ORIG-GUID: LM0nRGh10tyayoLqRI3X_9qqXGu5pff3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-20_06,2024-02-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1034 mlxlogscore=433 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402210074 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NEUTRAL, 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: 1791501585627122158 X-GMAIL-MSGID: 1791501585627122158 This patch implements built-in trait for std::remove_all_extents. gcc/cp/ChangeLog: * cp-trait.def: Define __remove_all_extents. * semantics.cc (finish_trait_type): Handle CPTK_REMOVE_ALL_EXTENTS. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __remove_all_extents. * g++.dg/ext/remove_all_extents.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 3 +++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 +++ gcc/testsuite/g++.dg/ext/remove_all_extents.C | 16 ++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/remove_all_extents.C diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 577c96d579b..933c8bcbe68 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -98,6 +98,7 @@ DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2) +DEFTRAIT_TYPE (REMOVE_ALL_EXTENTS, "__remove_all_extents", 1) DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1) DEFTRAIT_TYPE (REMOVE_CVREF, "__remove_cvref", 1) DEFTRAIT_TYPE (REMOVE_EXTENT, "__remove_extent", 1) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 58696225fc4..078424dac23 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12785,6 +12785,9 @@ finish_trait_type (cp_trait_kind kind, tree type1, tree type2, type1 = TREE_TYPE (type1); return build_pointer_type (type1); + case CPTK_REMOVE_ALL_EXTENTS: + return strip_array_types (type1); + case CPTK_REMOVE_CV: return cv_unqualified (type1); diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index 5d5cbe3b019..85b74bd676b 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -176,6 +176,9 @@ #if !__has_builtin (__reference_converts_from_temporary) # error "__has_builtin (__reference_converts_from_temporary) failed" #endif +#if !__has_builtin (__remove_all_extents) +# error "__has_builtin (__remove_all_extents) failed" +#endif #if !__has_builtin (__remove_cv) # error "__has_builtin (__remove_cv) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/remove_all_extents.C b/gcc/testsuite/g++.dg/ext/remove_all_extents.C new file mode 100644 index 00000000000..60ade2ade7f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/remove_all_extents.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +class ClassType { }; + +SA(__is_same(__remove_all_extents(int), int)); +SA(__is_same(__remove_all_extents(int[2]), int)); +SA(__is_same(__remove_all_extents(int[2][3]), int)); +SA(__is_same(__remove_all_extents(int[][3]), int)); +SA(__is_same(__remove_all_extents(const int[2][3]), const int)); +SA(__is_same(__remove_all_extents(ClassType), ClassType)); +SA(__is_same(__remove_all_extents(ClassType[2]), ClassType)); +SA(__is_same(__remove_all_extents(ClassType[2][3]), ClassType)); +SA(__is_same(__remove_all_extents(ClassType[][3]), ClassType)); +SA(__is_same(__remove_all_extents(const ClassType[2][3]), const ClassType));