public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Ken Matsui <kmatsui@gcc.gnu.org>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH v2 3/4] c++: Implement __remove_extent built-in trait
Date: Wed, 14 Feb 2024 15:20:09 -0500 (EST)	[thread overview]
Message-ID: <3c755462-9a60-4ba7-fbc0-214683c9ac1c@idea> (raw)
In-Reply-To: <20240214135252.1416047-3-kmatsui@gcc.gnu.org>

On Wed, 14 Feb 2024, Ken Matsui wrote:

> This patch implements built-in trait for std::remove_extent.
> 
> gcc/cp/ChangeLog:
> 
> 	* cp-trait.def: Define __remove_extent.
> 	* semantics.cc (finish_trait_type): Handle CPTK_REMOVE_EXTENT.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/ext/has-builtin-1.C: Test existence of __remove_extent.
> 	* g++.dg/ext/remove_extent.C: New test.

LGTM

> 
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
>  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_extent.C | 16 ++++++++++++++++
>  4 files changed, 25 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/ext/remove_extent.C
> 
> diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def
> index cec385ee501..3ff5611b60e 100644
> --- a/gcc/cp/cp-trait.def
> +++ b/gcc/cp/cp-trait.def
> @@ -96,6 +96,7 @@ DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_tempo
>  DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2)
>  DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1)
>  DEFTRAIT_TYPE (REMOVE_CVREF, "__remove_cvref", 1)
> +DEFTRAIT_TYPE (REMOVE_EXTENT, "__remove_extent", 1)
>  DEFTRAIT_TYPE (REMOVE_POINTER, "__remove_pointer", 1)
>  DEFTRAIT_TYPE (REMOVE_REFERENCE, "__remove_reference", 1)
>  DEFTRAIT_TYPE (TYPE_PACK_ELEMENT, "__type_pack_element", -1)
> diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
> index e23693ab57f..bf998377c88 100644
> --- a/gcc/cp/semantics.cc
> +++ b/gcc/cp/semantics.cc
> @@ -12777,6 +12777,11 @@ finish_trait_type (cp_trait_kind kind, tree type1, tree type2,
>  	type1 = TREE_TYPE (type1);
>        return cv_unqualified (type1);
>  
> +    case CPTK_REMOVE_EXTENT:
> +      if (TREE_CODE (type1) == ARRAY_TYPE)
> +	type1 = TREE_TYPE (type1);
> +      return type1;
> +
>      case CPTK_REMOVE_POINTER:
>        if (TYPE_PTR_P (type1))
>  	type1 = TREE_TYPE (type1);
> diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C
> index 56e8db7ac32..4f1094befb9 100644
> --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C
> +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C
> @@ -170,6 +170,9 @@
>  #if !__has_builtin (__remove_cvref)
>  # error "__has_builtin (__remove_cvref) failed"
>  #endif
> +#if !__has_builtin (__remove_extent)
> +# error "__has_builtin (__remove_extent) failed"
> +#endif
>  #if !__has_builtin (__remove_pointer)
>  # error "__has_builtin (__remove_pointer) failed"
>  #endif
> diff --git a/gcc/testsuite/g++.dg/ext/remove_extent.C b/gcc/testsuite/g++.dg/ext/remove_extent.C
> new file mode 100644
> index 00000000000..6183aca5a48
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/ext/remove_extent.C
> @@ -0,0 +1,16 @@
> +// { dg-do compile { target c++11 } }
> +
> +#define SA(X) static_assert((X),#X)
> +
> +class ClassType { };
> +
> +SA(__is_same(__remove_extent(int), int));
> +SA(__is_same(__remove_extent(int[2]), int));
> +SA(__is_same(__remove_extent(int[2][3]), int[3]));
> +SA(__is_same(__remove_extent(int[][3]), int[3]));
> +SA(__is_same(__remove_extent(const int[2]), const int));
> +SA(__is_same(__remove_extent(ClassType), ClassType));
> +SA(__is_same(__remove_extent(ClassType[2]), ClassType));
> +SA(__is_same(__remove_extent(ClassType[2][3]), ClassType[3]));
> +SA(__is_same(__remove_extent(ClassType[][3]), ClassType[3]));
> +SA(__is_same(__remove_extent(const ClassType[2]), const ClassType));
> -- 
> 2.43.0
> 
> 


  reply	other threads:[~2024-02-14 20:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 11:44 [PATCH 1/2] c++: Implement __add_pointer " Ken Matsui
2024-02-14 11:44 ` [PATCH 2/2] libstdc++: Optimize std::add_pointer compilation performance Ken Matsui
2024-02-14 13:52 ` [PATCH v2 1/4] c++: Implement __add_pointer built-in trait Ken Matsui
2024-02-14 13:52   ` [PATCH v2 2/4] libstdc++: Optimize std::add_pointer compilation performance Ken Matsui
2024-02-14 20:20     ` Patrick Palka
2024-02-14 13:52   ` [PATCH v2 3/4] c++: Implement __remove_extent built-in trait Ken Matsui
2024-02-14 20:20     ` Patrick Palka [this message]
2024-02-14 13:52   ` [PATCH v2 4/4] libstdc++: Optimize std::remove_extent compilation performance Ken Matsui
2024-02-14 20:21     ` Patrick Palka
2024-02-14 20:18   ` [PATCH v2 1/4] c++: Implement __add_pointer built-in trait Patrick Palka
2024-02-15  4:17     ` Ken Matsui
2024-02-15  4:52   ` [PATCH v3 " Ken Matsui
2024-02-15 12:48     ` [PATCH v4 05/12] c++: Implement __remove_all_extents " Ken Matsui
2024-02-15 12:48     ` [PATCH v4 06/12] libstdc++: Optimize std::remove_all_extents compilation performance Ken Matsui
2024-02-15 12:48     ` [PATCH v4 07/12] c++: Implement __add_lvalue_reference built-in trait Ken Matsui
2024-02-15 12:48     ` [PATCH v4 08/12] libstdc++: Optimize std::add_lvalue_reference compilation performance Ken Matsui
2024-02-15 12:48     ` [PATCH v4 09/12] c++: Implement __add_rvalue_reference built-in trait Ken Matsui
2024-02-15 12:48     ` [PATCH v4 10/12] libstdc++: Optimize std::add_rvalue_reference compilation performance Ken Matsui
2024-02-15 12:48     ` [PATCH v4 11/12] c++: Implement __decay built-in trait Ken Matsui
2024-02-15 12:48     ` [PATCH v4 12/12] libstdc++: Optimize std::decay compilation performance Ken Matsui
2024-02-15 15:20     ` [PATCH v5 01/14] c++: Implement __add_pointer built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 02/14] libstdc++: Optimize std::add_pointer compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 03/14] c++: Implement __remove_extent built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 04/14] libstdc++: Optimize std::remove_extent compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 05/14] c++: Implement __remove_all_extents built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 06/14] libstdc++: Optimize std::remove_all_extents compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 07/14] c++: Implement __add_lvalue_reference built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 08/14] libstdc++: Optimize std::add_lvalue_reference compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 09/14] c++: Implement __add_rvalue_reference built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 10/14] libstdc++: Optimize std::add_rvalue_reference compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 11/14] c++: Implement __decay built-in trait Ken Matsui
2024-02-15 15:20       ` [PATCH v5 12/14] libstdc++: Optimize std::decay compilation performance Ken Matsui
2024-02-15 15:20       ` [PATCH v5 13/14] c++: Implement __rank built-in trait Ken Matsui
2024-02-15 21:48         ` Patrick Palka
2024-02-16  2:14           ` Ken Matsui
2024-02-16  2:22             ` Ken Matsui
2024-02-16  2:15         ` [PATCH v6 " Ken Matsui
2024-02-15 15:20       ` [PATCH v5 14/14] libstdc++: Optimize std::rank compilation performance Ken Matsui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c755462-9a60-4ba7-fbc0-214683c9ac1c@idea \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kmatsui@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).