From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by sourceware.org (Postfix) with ESMTPS id 6CC22385842C for ; Mon, 4 Sep 2023 15:00:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CC22385842C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-44d38d91885so601291137.1 for ; Mon, 04 Sep 2023 08:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1693839645; x=1694444445; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zoLpIUJcbMcP571YfSwWT/Mo8Pwkaz3/5y0twuZxtNw=; b=V6hpH+3iGl/lnHnaWyYs4aS6+jIQXe6ZnxUEgTQvUahv8KAXDDV4qOFIa99wX9TuDm 0/hHShfDqxnCTnSlIwWijaXisHIVXBxyjqHbidKXkG7NKB5UEVymZfC/xK9WdJEmpfWe DozmeHlo4KqC67cbhxo9YYfDzUPqoiLcPKH7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693839645; x=1694444445; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zoLpIUJcbMcP571YfSwWT/Mo8Pwkaz3/5y0twuZxtNw=; b=YkeQEUvGoSEa1TbiA6gLqZwu+cHvVs9AYtm1GKn3PXYFXRBMV7FapQCVpEx//XT7jk AB513Td+UutiduEDyn3rLPM8L5/1vvqapZYYJb2gfTLja8GG2aZU9/bwyp6vHmylW/ag EZEeu2E0AE9/Kp1ALZogTqkR56wLDMrHiTpvJ08TJ11cOaEElIHM3xWzVdlcLYvwEEac SLc+zSWyUitjvQTBGHnb6aAtlllDy6VrVJPyi1htGcklKN0ji5hPCpAr95T/ZG3uCgwW fXXeJVcTbVbkUAuKB9PomrNQ/70i1VguFoxaJisaNBM1B+jCsgtCTQnyfIByXNAXbcME XcDg== X-Gm-Message-State: AOJu0YwakYJQQ+9gCkgLhdIU60nmv7cJ9wNYj8DIl1DCYoXVOAt9sh04 Sv+HtoJ8iHpzb2xAHUjSlA0ZVX/eUvRlbTdvaGCDlF+opO9ZIO3N X-Google-Smtp-Source: AGHT+IEuiT++mHOY/CwmZhI2HRu5BQBw8WX32kC/bpYXu6+Ni+y6WqB0Czz+/Cz54wyK3rsGlUVL+Vt/AnNbZpjBBLQ= X-Received: by 2002:a67:b348:0:b0:44d:4dd6:7966 with SMTP id b8-20020a67b348000000b0044d4dd67966mr9149440vsm.34.1693839644830; Mon, 04 Sep 2023 08:00:44 -0700 (PDT) MIME-Version: 1.0 References: <20230624101210.57519-1-kmatsui@cs.washington.edu> <20230708052928.67485-1-kmatsui@gcc.gnu.org> In-Reply-To: <20230708052928.67485-1-kmatsui@gcc.gnu.org> From: Ken Matsui Date: Mon, 4 Sep 2023 08:00:00 -0700 Message-ID: Subject: [PING][PATCH v2 1/2] c++: implement __remove_pointer built-in trait To: jason@redhat.com Cc: gcc-patches , "libstdc++" , Ken Matsui Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: Ping for __remove_pointer built-in. Sincerely, Ken Matsui On Fri, Jul 7, 2023 at 10:29=E2=80=AFPM Ken Matsui wr= ote: > > This patch implements built-in trait for std::remove_pointer. > > gcc/cp/ChangeLog: > > * cp-trait.def: Define __remove_pointer. > * semantics.cc (finish_trait_type): Handle CPTK_REMOVE_POINTER. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/has-builtin-1.C: Test existence of __remove_pointer. > * g++.dg/ext/remove_pointer.C: New test. > > Signed-off-by: Ken Matsui > --- > gcc/cp/cp-trait.def | 1 + > gcc/cp/semantics.cc | 5 +++ > gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ > gcc/testsuite/g++.dg/ext/remove_pointer.C | 51 +++++++++++++++++++++++ > 4 files changed, 60 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/ext/remove_pointer.C > > diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def > index 8b7fece0cc8..07823e55579 100644 > --- a/gcc/cp/cp-trait.def > +++ b/gcc/cp/cp-trait.def > @@ -90,6 +90,7 @@ DEFTRAIT_EXPR (IS_DEDUCIBLE, "__is_deducible ", 2) > DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1) > DEFTRAIT_TYPE (REMOVE_REFERENCE, "__remove_reference", 1) > DEFTRAIT_TYPE (REMOVE_CVREF, "__remove_cvref", 1) > +DEFTRAIT_TYPE (REMOVE_POINTER, "__remove_pointer", 1) > DEFTRAIT_TYPE (UNDERLYING_TYPE, "__underlying_type", 1) > DEFTRAIT_TYPE (TYPE_PACK_ELEMENT, "__type_pack_element", -1) > > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index 8fb47fd179e..a3b283ce938 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -12374,6 +12374,11 @@ finish_trait_type (cp_trait_kind kind, tree type= 1, tree type2, > type1 =3D TREE_TYPE (type1); > return cv_unqualified (type1); > > + case CPTK_REMOVE_POINTER: > + if (TYPE_PTR_P (type1)) > + type1 =3D TREE_TYPE (type1); > + return type1; > + > case CPTK_TYPE_PACK_ELEMENT: > return finish_type_pack_element (type1, type2, complain); > > diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++= .dg/ext/has-builtin-1.C > index f343e153e56..e21e0a95509 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 (__remove_pointer) > +# error "__has_builtin (__remove_pointer) failed" > +#endif > diff --git a/gcc/testsuite/g++.dg/ext/remove_pointer.C b/gcc/testsuite/g+= +.dg/ext/remove_pointer.C > new file mode 100644 > index 00000000000..7b13db93950 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/remove_pointer.C > @@ -0,0 +1,51 @@ > +// { dg-do compile { target c++11 } } > + > +#define SA(X) static_assert((X),#X) > + > +SA(__is_same(__remove_pointer(int), int)); > +SA(__is_same(__remove_pointer(int*), int)); > +SA(__is_same(__remove_pointer(int**), int*)); > + > +SA(__is_same(__remove_pointer(const int*), const int)); > +SA(__is_same(__remove_pointer(const int**), const int*)); > +SA(__is_same(__remove_pointer(int* const), int)); > +SA(__is_same(__remove_pointer(int** const), int*)); > +SA(__is_same(__remove_pointer(int* const* const), int* const)); > + > +SA(__is_same(__remove_pointer(volatile int*), volatile int)); > +SA(__is_same(__remove_pointer(volatile int**), volatile int*)); > +SA(__is_same(__remove_pointer(int* volatile), int)); > +SA(__is_same(__remove_pointer(int** volatile), int*)); > +SA(__is_same(__remove_pointer(int* volatile* volatile), int* volatile)); > + > +SA(__is_same(__remove_pointer(const volatile int*), const volatile int))= ; > +SA(__is_same(__remove_pointer(const volatile int**), const volatile int*= )); > +SA(__is_same(__remove_pointer(const int* volatile), const int)); > +SA(__is_same(__remove_pointer(volatile int* const), volatile int)); > +SA(__is_same(__remove_pointer(int* const volatile), int)); > +SA(__is_same(__remove_pointer(const int** volatile), const int*)); > +SA(__is_same(__remove_pointer(volatile int** const), volatile int*)); > +SA(__is_same(__remove_pointer(int** const volatile), int*)); > +SA(__is_same(__remove_pointer(int* const* const volatile), int* const)); > +SA(__is_same(__remove_pointer(int* volatile* const volatile), int* volat= ile)); > +SA(__is_same(__remove_pointer(int* const volatile* const volatile), int*= const volatile)); > + > +SA(__is_same(__remove_pointer(int&), int&)); > +SA(__is_same(__remove_pointer(const int&), const int&)); > +SA(__is_same(__remove_pointer(volatile int&), volatile int&)); > +SA(__is_same(__remove_pointer(const volatile int&), const volatile int&)= ); > + > +SA(__is_same(__remove_pointer(int&&), int&&)); > +SA(__is_same(__remove_pointer(const int&&), const int&&)); > +SA(__is_same(__remove_pointer(volatile int&&), volatile int&&)); > +SA(__is_same(__remove_pointer(const volatile int&&), const volatile int&= &)); > + > +SA(__is_same(__remove_pointer(int[3]), int[3])); > +SA(__is_same(__remove_pointer(const int[3]), const int[3])); > +SA(__is_same(__remove_pointer(volatile int[3]), volatile int[3])); > +SA(__is_same(__remove_pointer(const volatile int[3]), const volatile int= [3])); > + > +SA(__is_same(__remove_pointer(int(int)), int(int))); > +SA(__is_same(__remove_pointer(int(*const)(int)), int(int))); > +SA(__is_same(__remove_pointer(int(*volatile)(int)), int(int))); > +SA(__is_same(__remove_pointer(int(*const volatile)(int)), int(int))); > -- > 2.41.0 >