From patchwork Mon Jul 10 05:23:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 117603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4793287vqx; Sun, 9 Jul 2023 22:24:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKdFc3jqBcpLZH31v4yTkM7z1E1PhahI74pWq1DJz0GDp37Ij5jpfF6fzPY8NQ4z7rUGZC X-Received: by 2002:a17:906:77da:b0:993:d96d:79ec with SMTP id m26-20020a17090677da00b00993d96d79ecmr8126389ejn.16.1688966642413; Sun, 09 Jul 2023 22:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688966642; cv=none; d=google.com; s=arc-20160816; b=KcOBOHpB7yOiY45TEg/mx8RZh6DgGT2i2aok6KJ2gmkxCHquUhe2MRgdgJMG+lm4Im czrZNiRVUqj14gKG5tw5ll1tj21kyUIfn2npFWpACKgFZ3/lUYQSukNskS4ivMSb15jp 8y1CeqTDOzPLpFawDBpdX/TXthsPk6YaDNhu78hPqkPGIa/uNQrP4vSv5+nj46KOtQu0 j8QQ8Z7IOS+t71E6GvB3mXaAAkcCVGQeRZRknEAHP1AXRsYS8AxTB3cIp5I8ZdeAaUdj oEFuaR9ZL96ZcL3xpACqCDlWgbALrzGyIqDEiCw1FYldnwYCWpnPvlZqd7TTglEcJDRi qXrg== 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-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=U+xCdEuCTMgcq6zMB7zLFBRUYgWJ29jKAPUIGP8nC90=; fh=1CAabwJrK+ugngH18pg8mqZVlwzSJe6ffxxXK5OO7Vs=; b=OtRT0t9QnVM7sxHXi2gIn7mA4FrcpIv8I8sxrZanvioJygzrbeWL7Xl7xQC+P8h7BE kfWZnSseLIRUo9+OE5IxI7UJVJbHr2vquum6Uz/q2jWKro/KKnw2rYK0tEpbzWNwofGL dbrsgvZVXqcEtIramOfbxwXwYdkae1RhCWed50KTC7ayQ0q0xry5dMn6xsWGGr6/3u44 7qCKoQLkyjuTnO1wWEOb4ZWGeSrtwCrbUQbpSjBeSHn2coHZPlOJzMCYM8a5Gx7GOMI0 8Msep3cFhj2deGrsKUQBlwjsnI8gTWZ607/0aOgU42nzN9ktVJfmQViWxKhfCOMtB7N1 fb3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x8BkMzcz; 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 f21-20020a1709064dd500b00992ee6da4b2si7096435ejw.683.2023.07.09.22.24.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 22:24:02 -0700 (PDT) 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=x8BkMzcz; 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 059CC3857B9B for ; Mon, 10 Jul 2023 05:24:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 059CC3857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688966641; bh=U+xCdEuCTMgcq6zMB7zLFBRUYgWJ29jKAPUIGP8nC90=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=x8BkMzczqv3imzyqYVTrbicv+vr8mVs7VEeJdgxHAm2DHGbXyuzFhxdZJeMkeyULk Iv8+Guct4X7RQHS9wWSjSuwd92RQSwxI7S5OzvKGO2C9AvdK6mmLtqC4k7znJCcKDC 2FdK7AN35/zCZcC+Mc6qdF9Ej4WciofseMixvyJw= 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 1672F3858D3C; Mon, 10 Jul 2023 05:23:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1672F3858D3C 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 36A5J2Rk005941; Mon, 10 Jul 2023 05:23:15 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3rqhxxvka0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jul 2023 05:23:15 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 36A5NCJp016879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 9 Jul 2023 22:23:12 -0700 X-Auth-Received: from localhost.localdomain ([10.154.74.234]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 36A5NBK5025924 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sun, 9 Jul 2023 22:23:12 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH 1/2] c++, libstdc++: implement __is_pointer built-in trait Date: Sun, 9 Jul 2023 22:23:09 -0700 Message-ID: <20230710052310.48116-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Proofpoint-GUID: Am5BMayjoOXW9w_mlQuMGulYOYQf5Wur X-Proofpoint-ORIG-GUID: Am5BMayjoOXW9w_mlQuMGulYOYQf5Wur X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-10_04,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1034 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307100048 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ken Matsui via Gcc-patches From: Ken Matsui Reply-To: Ken Matsui Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771009885939018345 X-GMAIL-MSGID: 1771009885939018345 This patch implements built-in trait for std::is_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer. * g++.dg/ext/is_pointer.C: New test. * g++.dg/tm/pr46567.C (__is_pointer): Rename to ... (____is_pointer): ... this. * g++.dg/torture/20070621-1.C: Likewise. * g++.dg/torture/pr57107.C: Likewise. libstdc++-v3/ChangeLog: * include/bits/cpp_type_traits.h (__is_pointer): Rename to ... (____is_pointer): ... this. * include/bits/deque.tcc: Use ____is_pointer instead. * include/bits/stl_algobase.h: Likewise. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 ++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 +++++++++++++++++++++ gcc/testsuite/g++.dg/tm/pr46567.C | 22 ++++----- gcc/testsuite/g++.dg/torture/20070621-1.C | 4 +- gcc/testsuite/g++.dg/torture/pr57107.C | 4 +- libstdc++-v3/include/bits/cpp_type_traits.h | 6 +-- libstdc++-v3/include/bits/deque.tcc | 6 +-- libstdc++-v3/include/bits/stl_algobase.h | 6 +-- 11 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 8cf0f2d0974..30266204eb5 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3751,6 +3751,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_UNION: inform (loc, " %qT is not a union", t1); break; + case CPTK_IS_POINTER: + inform (loc, " %qT is not a pointer", t1); + break; case CPTK_IS_AGGREGATE: inform (loc, " %qT is not an aggregate", t1); break; diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 8b7fece0cc8..b7c263e9a77 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -82,6 +82,7 @@ DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2) DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1) DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) +DEFTRAIT_EXPR (IS_POINTER, "__is_pointer", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2) /* FIXME Added space to avoid direct usage in GCC 13. */ diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 8fb47fd179e..68f8a4fe85b 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12118,6 +12118,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_UNION: return type_code1 == UNION_TYPE; + case CPTK_IS_POINTER: + return TYPE_PTR_P (type1); + case CPTK_IS_ASSIGNABLE: return is_xible (MODIFY_EXPR, type1, type2); @@ -12296,6 +12299,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_ENUM: case CPTK_IS_UNION: case CPTK_IS_SAME: + case CPTK_IS_POINTER: break; case CPTK_IS_LAYOUT_COMPATIBLE: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index f343e153e56..9dace5cbd48 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -146,3 +146,6 @@ #if !__has_builtin (__remove_cvref) # error "__has_builtin (__remove_cvref) failed" #endif +#if !__has_builtin (__is_pointer) +# error "__has_builtin (__is_pointer) failed" +#endif diff --git a/gcc/testsuite/g++.dg/ext/is_pointer.C b/gcc/testsuite/g++.dg/ext/is_pointer.C new file mode 100644 index 00000000000..d6e39565950 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_pointer.C @@ -0,0 +1,51 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +SA(!__is_pointer(int)); +SA(__is_pointer(int*)); +SA(__is_pointer(int**)); + +SA(__is_pointer(const int*)); +SA(__is_pointer(const int**)); +SA(__is_pointer(int* const)); +SA(__is_pointer(int** const)); +SA(__is_pointer(int* const* const)); + +SA(__is_pointer(volatile int*)); +SA(__is_pointer(volatile int**)); +SA(__is_pointer(int* volatile)); +SA(__is_pointer(int** volatile)); +SA(__is_pointer(int* volatile* volatile)); + +SA(__is_pointer(const volatile int*)); +SA(__is_pointer(const volatile int**)); +SA(__is_pointer(const int* volatile)); +SA(__is_pointer(volatile int* const)); +SA(__is_pointer(int* const volatile)); +SA(__is_pointer(const int** volatile)); +SA(__is_pointer(volatile int** const)); +SA(__is_pointer(int** const volatile)); +SA(__is_pointer(int* const* const volatile)); +SA(__is_pointer(int* volatile* const volatile)); +SA(__is_pointer(int* const volatile* const volatile)); + +SA(!__is_pointer(int&)); +SA(!__is_pointer(const int&)); +SA(!__is_pointer(volatile int&)); +SA(!__is_pointer(const volatile int&)); + +SA(!__is_pointer(int&&)); +SA(!__is_pointer(const int&&)); +SA(!__is_pointer(volatile int&&)); +SA(!__is_pointer(const volatile int&&)); + +SA(!__is_pointer(int[3])); +SA(!__is_pointer(const int[3])); +SA(!__is_pointer(volatile int[3])); +SA(!__is_pointer(const volatile int[3])); + +SA(!__is_pointer(int(int))); +SA(__is_pointer(int(*const)(int))); +SA(__is_pointer(int(*volatile)(int))); +SA(__is_pointer(int(*const volatile)(int))); diff --git a/gcc/testsuite/g++.dg/tm/pr46567.C b/gcc/testsuite/g++.dg/tm/pr46567.C index 6d791484448..0896035390e 100644 --- a/gcc/testsuite/g++.dg/tm/pr46567.C +++ b/gcc/testsuite/g++.dg/tm/pr46567.C @@ -192,13 +192,13 @@ namespace std __attribute__ ((__visibility__ ("default"))) { typedef __true_type __type; }; template - struct __is_pointer + struct ____is_pointer { enum { __value = 0 }; typedef __false_type __type; }; template - struct __is_pointer<_Tp*> + struct ____is_pointer<_Tp*> { enum { __value = 1 }; typedef __true_type __type; @@ -226,7 +226,7 @@ namespace std __attribute__ ((__visibility__ ("default"))) { { }; template struct __is_scalar - : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > + : public __traitor<__is_arithmetic<_Tp>, ____is_pointer<_Tp> > { }; template struct __is_char @@ -1202,8 +1202,8 @@ namespace std __attribute__ ((__visibility__ ("default"))) { typedef typename iterator_traits<_OI>::value_type _ValueTypeO; typedef typename iterator_traits<_II>::iterator_category _Category; const bool __simple = (__is_pod(_ValueTypeI) - && __is_pointer<_II>::__value - && __is_pointer<_OI>::__value + && ____is_pointer<_II>::__value + && ____is_pointer<_OI>::__value && __are_same<_ValueTypeI, _ValueTypeO>::__value); return std::__copy_move<_IsMove, __simple, _Category>::__copy_m(__first, __last, __result); @@ -1294,8 +1294,8 @@ namespace std __attribute__ ((__visibility__ ("default"))) { typedef typename iterator_traits<_BI2>::value_type _ValueType2; typedef typename iterator_traits<_BI1>::iterator_category _Category; const bool __simple = (__is_pod(_ValueType1) - && __is_pointer<_BI1>::__value - && __is_pointer<_BI2>::__value + && ____is_pointer<_BI1>::__value + && ____is_pointer<_BI2>::__value && __are_same<_ValueType1, _ValueType2>::__value); return std::__copy_move_backward<_IsMove, __simple, _Category>::__copy_move_b(__first, @@ -1426,8 +1426,8 @@ namespace std __attribute__ ((__visibility__ ("default"))) { typedef typename iterator_traits<_II1>::value_type _ValueType1; typedef typename iterator_traits<_II2>::value_type _ValueType2; const bool __simple = (__is_integer<_ValueType1>::__value - && __is_pointer<_II1>::__value - && __is_pointer<_II2>::__value + && ____is_pointer<_II1>::__value + && ____is_pointer<_II2>::__value && __are_same<_ValueType1, _ValueType2>::__value); return std::__equal<__simple>::equal(__first1, __last1, __first2); } @@ -1515,8 +1515,8 @@ namespace std __attribute__ ((__visibility__ ("default"))) { (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed - && __is_pointer<_II1>::__value - && __is_pointer<_II2>::__value); + && ____is_pointer<_II1>::__value + && ____is_pointer<_II2>::__value); return std::__lexicographical_compare<__simple>::__lc(__first1, __last1, __first2, __last2); } diff --git a/gcc/testsuite/g++.dg/torture/20070621-1.C b/gcc/testsuite/g++.dg/torture/20070621-1.C index d8a6a76b6b0..9ae96717e4f 100644 --- a/gcc/testsuite/g++.dg/torture/20070621-1.C +++ b/gcc/testsuite/g++.dg/torture/20070621-1.C @@ -18,7 +18,7 @@ namespace std __attribute__ ((__visibility__ ("default"))) { enum { __value = 0 }; }; - template struct __is_pointer { + template struct ____is_pointer { enum { __value = 0 }; }; @@ -49,7 +49,7 @@ namespace std __attribute__ ((__visibility__ ("default"))) { template inline bool __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) { typedef typename iterator_traits<_II1>::value_type _ValueType1; typedef typename iterator_traits<_II2>::value_type _ValueType2; - const bool __simple = (__is_integer<_ValueType1>::__value && __is_pointer<_II1>::__value && __is_pointer<_II2>::__value && __are_same<_ValueType1, _ValueType2>::__value); + const bool __simple = (__is_integer<_ValueType1>::__value && ____is_pointer<_II1>::__value && ____is_pointer<_II2>::__value && __are_same<_ValueType1, _ValueType2>::__value); return std::__equal<__simple>::equal(__first1, __last1, __first2); } template inline bool equal(_II1 __first1, _II1 __last1, _II2 __first2) { diff --git a/gcc/testsuite/g++.dg/torture/pr57107.C b/gcc/testsuite/g++.dg/torture/pr57107.C index 4dbd32bd298..1fcf337ee58 100644 --- a/gcc/testsuite/g++.dg/torture/pr57107.C +++ b/gcc/testsuite/g++.dg/torture/pr57107.C @@ -17,7 +17,7 @@ namespace std __attribute__ ((__visibility__ ("default"))) { enum { __value = 0 }; }; - template struct __is_pointer { + template struct ____is_pointer { enum { __value = 0 }; }; @@ -27,7 +27,7 @@ namespace std __attribute__ ((__visibility__ ("default"))) { }; template struct __is_arithmetic : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > { }; - template struct __is_scalar : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > { + template struct __is_scalar : public __traitor<__is_arithmetic<_Tp>, ____is_pointer<_Tp> > { }; } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 4312f32a4e0..3999898ffa6 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -364,14 +364,14 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // Pointer types // template - struct __is_pointer + struct ____is_pointer { enum { __value = 0 }; typedef __false_type __type; }; template - struct __is_pointer<_Tp*> + struct ____is_pointer<_Tp*> { enum { __value = 1 }; typedef __true_type __type; @@ -390,7 +390,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // template struct __is_scalar - : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > + : public __traitor<__is_arithmetic<_Tp>, ____is_pointer<_Tp> > { }; // diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index a212b8a6940..9f5593fac51 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -1273,7 +1273,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER { const bool __simple = (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value - && __is_pointer<_Ptr>::__value + && ____is_pointer<_Ptr>::__value #if __cplusplus > 201703L && __cpp_lib_concepts // For C++20 iterator_traits::value_type is non-volatile // so __is_byte could be true, but we can't use memcmp with @@ -1329,8 +1329,8 @@ _GLIBCXX_END_NAMESPACE_CONTAINER { const bool __simple = (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value - && __is_pointer<_Ptr1>::__value - && __is_pointer<_Ptr2>::__value + && ____is_pointer<_Ptr1>::__value + && ____is_pointer<_Ptr2>::__value #if __cplusplus > 201703L && __cpp_lib_concepts // For C++20 iterator_traits::value_type is non-volatile // so __is_byte could be true, but we can't use memcmp with diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index dd95e94f7e9..b061c6c1185 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -1214,7 +1214,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER { typedef typename iterator_traits<_II1>::value_type _ValueType1; const bool __simple = ((__is_integer<_ValueType1>::__value - || __is_pointer<_ValueType1>::__value) + || ____is_pointer<_ValueType1>::__value) && __memcmpable<_II1, _II2>::__value); return std::__equal<__simple>::equal(__first1, __last1, __first2); } @@ -1377,8 +1377,8 @@ _GLIBCXX_END_NAMESPACE_CONTAINER typedef typename iterator_traits<_II2>::value_type _ValueType2; const bool __simple = (__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value - && __is_pointer<_II1>::__value - && __is_pointer<_II2>::__value + && ____is_pointer<_II1>::__value + && ____is_pointer<_II2>::__value #if __cplusplus > 201703L && __cpp_lib_concepts // For C++20 iterator_traits::value_type is non-volatile // so __is_byte could be true, but we can't use memcmp with From patchwork Mon Jul 10 05:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 117604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4795402vqx; Sun, 9 Jul 2023 22:29:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1OzFKRc4bIr533beyNnXM1ZEQfxqjmJRs3J6UiOT5dEkj4J5jXbLFePKDsuU2QhBKdpbO X-Received: by 2002:a19:7710:0:b0:4fb:8a92:4fd5 with SMTP id s16-20020a197710000000b004fb8a924fd5mr8184598lfc.54.1688966991622; Sun, 09 Jul 2023 22:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688966991; cv=none; d=google.com; s=arc-20160816; b=Te9jTrmwLtMiUjso+soH7nDF/sFLqW2B9OGROjNSN72kK5xZiC8hrdxUhJ6qu8Ln93 APTG4ZZ8gID2zlrmsH2vHWQ5lmdFBrry5Quj4ue8qGg9bKPwQGx3wRnsNb4bFFchhkQc Dgn74xo51iirs9k4gOkGKZ5nVCRJEzNlIRJpMGqPnKUQ55fWP4LbqO0pyPMWnDEwRivk kN1d3bzSmocbmYd0PF6gCVA6NvU1UEzyLV/lpMXtZ7htjvOy7EEQ516R2RxM1GRhWgrj GYsgpZiEOlWPoEO5HvU7FyYQVpwiTTJtXOcyfz12D2RjjUigrGqjmjkL07uNz29WGEM8 Hz/w== 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-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=+x8MCd7xNeP71UXrri3KPgZy3ykmq6KJcbkqHY7uqOc=; fh=1CAabwJrK+ugngH18pg8mqZVlwzSJe6ffxxXK5OO7Vs=; b=RgQW/Rq51nR9KXTN7iXUXDzILekCa6y9mcM1Htukicd9GIzQHYYzckDNd22obmRT4q lK9K/wX4BccHnr3+tCYVqUIO93Ho4JqJ4MLHMVDubRYelK1WF1IitS56E0OTW/cCBcFb 8+2XW9F7BrZgReobmzd+rzI72JjE9M8BziV5aE+AuxIjt8LgaJL8BMcmwj9OGIn523VK GjWo6AVAGjlvhuKYo68QMlKT0K9JkCYDhcE6GcF1V31aWmMw/KJ3fwFazMYU/1LE6jkU ZJY+wTceF8bCnJpFJGmzQIGZNIk6EokUJ3FOWjfV8kvgx/KUs3ZlVrEv1gIiMKEMQirM WUig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vlaRLHMt; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c6-20020aa7c746000000b0051e0315eca0si7639426eds.58.2023.07.09.22.29.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 22:29:51 -0700 (PDT) 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=vlaRLHMt; 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 30D763854EB5 for ; Mon, 10 Jul 2023 05:25:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30D763854EB5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688966720; bh=+x8MCd7xNeP71UXrri3KPgZy3ykmq6KJcbkqHY7uqOc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=vlaRLHMt197osmZvDbDYa6GSQFW2EIWl2CBgmvhtSY4/cVDWLqlkA10ZxGWVeFb2W 1TR8U4d6SY68bgOOeoOdkrOw7if+rPZn1kss7wpeoWay3sSxgx7/YZT17MzksuPPcn 7Ljn+9ip012CH/YNFlrDFt39coMxSd0So5NpaLa8= 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 786F63858C3A; Mon, 10 Jul 2023 05:24:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 786F63858C3A Received: from pps.filterd (m0247479.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36A5HsRu032013; Mon, 10 Jul 2023 05:24:02 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3rqhdmvpb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jul 2023 05:24:02 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout26.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 36A5Nu87009961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 9 Jul 2023 22:23:56 -0700 X-Auth-Received: from localhost.localdomain ([10.154.74.234]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 36A5NBK6025924 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sun, 9 Jul 2023 22:23:56 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH 2/2] libstdc++: use new built-in trait __is_pointer Date: Sun, 9 Jul 2023 22:23:10 -0700 Message-ID: <20230710052310.48116-2-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230710052310.48116-1-kmatsui@gcc.gnu.org> References: <20230710052310.48116-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dbF4Dp-mHrD_iPilMy31P8dpBYlifdoC X-Proofpoint-GUID: dbF4Dp-mHrD_iPilMy31P8dpBYlifdoC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-10_04,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1034 mlxlogscore=821 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307100049 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ken Matsui via Gcc-patches From: Ken Matsui Reply-To: Ken Matsui Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771010252115508915 X-GMAIL-MSGID: 1771010252115508915 This patch lets libstdc++ use new built-in trait __is_pointer. libstdc++-v3/ChangeLog: * include/std/type_traits (is_pointer): Use __is_pointer built-in trait. (is_pointer_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 0e7a9c9c7f3..d83db98403b 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -515,6 +515,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_array<_Tp[]> : public true_type { }; + /// is_pointer +#if __has_builtin(__is_pointer) + template + struct is_pointer + : public __bool_constant<__is_pointer(_Tp)> + { }; +#else template struct __is_pointer_helper : public false_type { }; @@ -523,11 +530,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_pointer_helper<_Tp*> : public true_type { }; - /// is_pointer template struct is_pointer : public __is_pointer_helper<__remove_cv_t<_Tp>>::type { }; +#endif /// is_lvalue_reference template