From patchwork Thu Feb 15 12:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 201447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp372909dyb; Thu, 15 Feb 2024 04:50:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhroY8OYDUmMV3gHfszSIi3beiWgcgd341Rdw4Zrrzu+roh5R8u/vUOwKKANsluM6rJubKvJUiH/Nwv13x29vJF/r77A== X-Google-Smtp-Source: AGHT+IG7rOhK4UGRaWgjmZpBFIrtVrQLC5jJfWbXAVawR9TIlDMimiN5XR0iT7a9edlCc3hCtI/Y X-Received: by 2002:a05:622a:50e:b0:42c:5c56:bbd7 with SMTP id l14-20020a05622a050e00b0042c5c56bbd7mr1904438qtx.58.1708001429130; Thu, 15 Feb 2024 04:50:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708001429; cv=pass; d=google.com; s=arc-20160816; b=sJgjgx4o7AfdeBm6zZfr/AZMUZ3jw36pqFVbt7R2wEBQvz3ghYAHMgK97AMrYr8N+I cmF+8QAEV0DEkXkMhKtn9d9EG5U+T+pjH27WfllOQUAc+ajcSL/lmxdpsmoMxcyRBZcs QLFAdPvj+0f6zGMHKQH/Iefs3W5ikBcuuEG9eRRVAHil1uth5YMmD/XfGzFmWX67vRvs QsOK5b38gGp4WcfzlQzs+FiwB5B/nEUCxUFG0cI/Gt+NahJ/tJWDABUkILxlZ13uU7Vj YYiQn3NQGa0TpUcHo2BVOeFS0ifmSeNAZPDMfg+JAi6Rz1EHHbn7ua9drDEwyN0aqX/4 p7Kw== 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=HCkGcH645GYlpsk467qNsvGRbVZ+BGqmE4Ow5kk31wA=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=gDwLUXvikJHpyvlxy8PSz3OLLUaG3aK9W6KmJ7zb6VvB3iX750jfPBLzo+TAeo1Ege hTLqB8NVFnv2JHcAAIsZBmHGmdNIUB9xdbu8jI9XgjVere7nQBxbJPwzxVWqYotyXcgz IxoJzkWO68HEAVN64aXkNJDz+nSJ++3gxR0bbfCJjT+c75dvgKWSOFqpDniP8g0zPdNY xC5E4HFUXZl2wmOLfXoNEKZsILnbUEhV2xjOsqGRbndBVWbl610vROGijk3yIkkcTk2V y3uoWWVpA2MRKGgDfWiSYQinlz6Cv44CDcKNEtzI62sEsNf/EuoHEP+ZNLehHa/Umfrg l67Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rCskERgc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id 14-20020ac8574e000000b0042c7b08c78fsi1353488qtx.10.2024.02.15.04.50.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 04:50:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rCskERgc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 B4DBA3864C5B for ; Thu, 15 Feb 2024 12:50:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4DBA3864C5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708001428; bh=HCkGcH645GYlpsk467qNsvGRbVZ+BGqmE4Ow5kk31wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rCskERgcAnbc83nkMKHwJqKpN+qW0dlgzKVREDoqHBRfAWB/r93OJs8tSNvUQVsTD tf6fAi3E2D2taPI9irxDDD8mqDvIr4Glq3VZN/M1TKQfbYF6OTgloB4MGRwRx3WiAj 51aiRQMhFYldD2tOzBeDMYj/BTCwAemBK3FfXOxk= 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 A0AE7384F4B8; Thu, 15 Feb 2024 12:48:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0AE7384F4B8 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 A0AE7384F4B8 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=1708001342; cv=none; b=T9R4uu7eqXdV7ob8dWf0TZFxcn4yCEaMTgczspD67PIQDMmgiKMFit4GzUJoPPj533LcoKO0zGFaVzxJNc7Jh6gFZvMMtM4nqo93Gm1ftS2U22Ot2YGvz4yxUG9w/c3q4s/9EpGE1nhOmhZZdUmjxqKExw8Q7jCe7lW3dp0zYbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708001342; c=relaxed/simple; bh=NjJ+uIp1zaFFdm3eVt+eosLgH99G1zJ2njjkimdG3jU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=wp+gAFoMasXYDpte8GNXFKhW5XyAKnx9pbqt6LtHmjdi2Qs/PpC19jeM0Dad0IEvOEPlLZXn6wLn/HetDC/DXkkUnn5a74gjTs1Vgs6J7ojykHDgQ/gjaN20GatfqzQEQYI/x4h36vqyJOvpblv3ZOyhS9Tm/AieFWBbXSidUA4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247480.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FCm7Ao019799; Thu, 15 Feb 2024 12:48:51 GMT Received: from mxout21.s.uw.edu (mxout21.s.uw.edu [140.142.32.139]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3w950xvbvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 12:48:50 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout21.s.uw.edu (8.14.4+UW20.07/8.14.4+UW24.02) with ESMTP id 41FCmcRx022591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 04:48:38 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW24.02) with ESMTPSA id 41FCmbNw021397 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 04:48:37 -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 v4 05/12] c++: Implement __remove_all_extents built-in trait Date: Thu, 15 Feb 2024 04:48:17 -0800 Message-ID: <20240215124824.310810-5-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215045258.3025806-1-kmatsui@gcc.gnu.org> References: <20240215045258.3025806-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: qYH9L2Af0-OsKZvPLs1-j_NvcJFzoLcD X-Proofpoint-ORIG-GUID: qYH9L2Af0-OsKZvPLs1-j_NvcJFzoLcD 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-15_12,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=463 impostorscore=0 clxscore=1034 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150102 X-Spam-Status: No, score=-13.2 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: 1790969306559142639 X-GMAIL-MSGID: 1790969306559142639 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 3ff5611b60e..ce29108bad6 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -94,6 +94,7 @@ DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 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 6ab054b106a..c8ac5167c3c 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12769,6 +12769,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 4f1094befb9..9af64173524 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -164,6 +164,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));