From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by sourceware.org (Postfix) with ESMTPS id 85AE9385480B for ; Mon, 20 Mar 2023 22:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85AE9385480B 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-xe32.google.com with SMTP id cz11so5456606vsb.6 for ; Mon, 20 Mar 2023 15:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1679351092; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=H+fH2MOWi0RnQTF27dhrFNpmtDtGT1MaiK2rfiJ2Pog=; b=gYR5q8IHYjB0k62eJMtOlVITjwmTN601O5esRNR7W2G/QM0sFoUHJxTtwO9RUWODcN 0wV1jnFmhVUyaXSfd3xtSnSEqqckc5zF8PPmU1gPaYFpe4Rl5YBRbltGyacCzvDg7Ttw yY6vkBNkNxxh5krB0aav/9dZhFAxr/rba6NgU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679351092; h=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=H+fH2MOWi0RnQTF27dhrFNpmtDtGT1MaiK2rfiJ2Pog=; b=zFSYHwEx51lzvhQw6E2SuoUCh4vfobKiDwbSVaSa1AMAtqs4EKv6NhQ5n+jaCnQVBB qMsZIMPucxgQGKF3QgXIT197nFWu8UCPoFMr34RFfDpWlrZFgTUliHZdMoDO5z6iA/Wr yxpZUIv/v0LyyfWz3bUC0SGvRmqGm00+xLDI7GrGu74/4an/I2n71RfLCYMZceu887De 50uogbuTOThBGp74Ek4ZsH5l752tKM9SS9zZLDwFTNjxUJptbUAHb/E83qf4lPz8LpjF leGQeuwsQ4x4Cm5SxDbuMB1rPZTaYHTVP7zwI6LXTUWr6Vt9wFiuz4UVJMypGrhJG0ZT ZO4Q== X-Gm-Message-State: AAQBX9cv+xVaihHTC6llbITk14nmBB0vS6cbqVpkTXzPzRa3ew9w8vu5 2t9OsuXhZI+d6aTa8/1N8jUyPh1nlWB1P7Axt0oNDWTdkTfjG/vi X-Google-Smtp-Source: AK7set8AuaeMJvczpi4BxaIyRE2y/S2pjx9AkEbbAiI+okJRxYaMhMtfiP1HyngFik/83QP+lhqns3E0y580sduI8cM= X-Received: by 2002:a67:d395:0:b0:425:e8fe:f59b with SMTP id b21-20020a67d395000000b00425e8fef59bmr382598vsj.6.1679351092709; Mon, 20 Mar 2023 15:24:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ken Matsui Date: Mon, 20 Mar 2023 15:24:42 -0700 Message-ID: Subject: Re: [PATCH] c++: implement __remove_pointer built-in trait To: gcc-patches@gcc.gnu.org Cc: Patrick Palka Content-Type: multipart/alternative; boundary="000000000000559ef905f75c651d" X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HTML_MESSAGE,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: --000000000000559ef905f75c651d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Please disregard this email. On Sun, Mar 19, 2023 at 1:21=E2=80=AFPM Ken Matsui wrote: > 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. > > --- > diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def > index bac593c0094..985b43e0d97 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) > > /* These traits yield a type pack, not a type, and are represented by > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index 87c2e8a7111..92db1f670ac 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -12273,6 +12273,10 @@ finish_trait_type (cp_trait_kind kind, tree > type1, tree type2) > if (TYPE_REF_P (type1)) > 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; > > #define DEFTRAIT_EXPR(CODE, NAME, ARITY) \ > case CPTK_##CODE: > 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* > volatile)); > +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))); > --000000000000559ef905f75c651d--