diff mbox series

c++: further concept_check_p clean-up

Message ID 20240806160951.860249-1-polacek@redhat.com
State New
Headers show
Series c++: further concept_check_p clean-up | expand

Commit Message

Marek Polacek Aug. 6, 2024, 4:09 p.m. UTC
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

-- >8 --
Patrick noticed a few more concept_check_p checks that can be removed
now.

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Remove concept_check_p check.
	(cxx_eval_outermost_constant_expr): Likewise.
	* cp-gimplify.cc (cp_genericize_r) <case CALL_EXPR>: Likewise.
	* except.cc (check_noexcept_r): Likewise.
---
 gcc/cp/constexpr.cc   | 20 ++++++--------------
 gcc/cp/cp-gimplify.cc |  9 ---------
 gcc/cp/except.cc      |  2 --
 3 files changed, 6 insertions(+), 25 deletions(-)


base-commit: 180625ae72b3f733813a360fae4f0d6ce79eccdc

Comments

Patrick Palka Aug. 6, 2024, 4:58 p.m. UTC | #1
On Tue, 6 Aug 2024, Marek Polacek wrote:

> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

LGTM

> 
> -- >8 --
> Patrick noticed a few more concept_check_p checks that can be removed
> now.
> 
> gcc/cp/ChangeLog:
> 
> 	* constexpr.cc (cxx_eval_call_expression): Remove concept_check_p check.
> 	(cxx_eval_outermost_constant_expr): Likewise.
> 	* cp-gimplify.cc (cp_genericize_r) <case CALL_EXPR>: Likewise.
> 	* except.cc (check_noexcept_r): Likewise.
> ---
>  gcc/cp/constexpr.cc   | 20 ++++++--------------
>  gcc/cp/cp-gimplify.cc |  9 ---------
>  gcc/cp/except.cc      |  2 --
>  3 files changed, 6 insertions(+), 25 deletions(-)
> 
> diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
> index 8d994f0ee53..b0adbb9036d 100644
> --- a/gcc/cp/constexpr.cc
> +++ b/gcc/cp/constexpr.cc
> @@ -2797,10 +2797,6 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
>  			  value_cat lval,
>  			  bool *non_constant_p, bool *overflow_p)
>  {
> -  /* Handle concept checks separately.  */
> -  if (concept_check_p (t))
> -    return evaluate_concept_check (t);
> -
>    location_t loc = cp_expr_loc_or_input_loc (t);
>    tree fun = get_function_named_in_call (t);
>    constexpr_call new_call
> @@ -8774,16 +8770,12 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
>  	       || TREE_CODE (t) == AGGR_INIT_EXPR
>  	       || TREE_CODE (t) == TARGET_EXPR))
>      {
> -      /* For non-concept checks, determine if it is consteval.  */
> -      if (!concept_check_p (t))
> -	{
> -	  tree x = t;
> -	  if (TREE_CODE (x) == TARGET_EXPR)
> -	    x = TARGET_EXPR_INITIAL (x);
> -	  tree fndecl = cp_get_callee_fndecl_nofold (x);
> -	  if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
> -	    is_consteval = true;
> -	}
> +      tree x = t;
> +      if (TREE_CODE (x) == TARGET_EXPR)
> +	x = TARGET_EXPR_INITIAL (x);
> +      tree fndecl = cp_get_callee_fndecl_nofold (x);
> +      if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
> +	is_consteval = true;
>      }
>    if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
>      {
> diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
> index 0c589eeaaec..003e68f1ea7 100644
> --- a/gcc/cp/cp-gimplify.cc
> +++ b/gcc/cp/cp-gimplify.cc
> @@ -2092,15 +2092,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
>        break;
>  
>      case CALL_EXPR:
> -      /* Evaluate function concept checks instead of treating them as
> -	 normal functions.  */
> -      if (concept_check_p (stmt))
> -	{
> -	  *stmt_p = evaluate_concept_check (stmt);
> -	  * walk_subtrees = 0;
> -	  break;
> -	}
> -
>        if (!wtd->no_sanitize_p
>  	  && sanitize_flags_p ((SANITIZE_NULL
>  				| SANITIZE_ALIGNMENT | SANITIZE_VPTR)))
> diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc
> index 3c69ab69502..0231bd2507d 100644
> --- a/gcc/cp/except.cc
> +++ b/gcc/cp/except.cc
> @@ -1074,8 +1074,6 @@ check_noexcept_r (tree *tp, int *walk_subtrees, void *)
>  
>           We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */
>        tree fn = cp_get_callee (t);
> -      if (concept_check_p (fn))
> -	return NULL_TREE;
>        tree type = TREE_TYPE (fn);
>        gcc_assert (INDIRECT_TYPE_P (type));
>        type = TREE_TYPE (type);
> 
> base-commit: 180625ae72b3f733813a360fae4f0d6ce79eccdc
> -- 
> 2.45.2
> 
>
Jason Merrill Aug. 6, 2024, 5:10 p.m. UTC | #2
On 8/6/24 12:09 PM, Marek Polacek wrote:
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

OK.

> -- >8 --
> Patrick noticed a few more concept_check_p checks that can be removed
> now.
> 
> gcc/cp/ChangeLog:
> 
> 	* constexpr.cc (cxx_eval_call_expression): Remove concept_check_p check.
> 	(cxx_eval_outermost_constant_expr): Likewise.
> 	* cp-gimplify.cc (cp_genericize_r) <case CALL_EXPR>: Likewise.
> 	* except.cc (check_noexcept_r): Likewise.
> ---
>   gcc/cp/constexpr.cc   | 20 ++++++--------------
>   gcc/cp/cp-gimplify.cc |  9 ---------
>   gcc/cp/except.cc      |  2 --
>   3 files changed, 6 insertions(+), 25 deletions(-)
> 
> diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
> index 8d994f0ee53..b0adbb9036d 100644
> --- a/gcc/cp/constexpr.cc
> +++ b/gcc/cp/constexpr.cc
> @@ -2797,10 +2797,6 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
>   			  value_cat lval,
>   			  bool *non_constant_p, bool *overflow_p)
>   {
> -  /* Handle concept checks separately.  */
> -  if (concept_check_p (t))
> -    return evaluate_concept_check (t);
> -
>     location_t loc = cp_expr_loc_or_input_loc (t);
>     tree fun = get_function_named_in_call (t);
>     constexpr_call new_call
> @@ -8774,16 +8770,12 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
>   	       || TREE_CODE (t) == AGGR_INIT_EXPR
>   	       || TREE_CODE (t) == TARGET_EXPR))
>       {
> -      /* For non-concept checks, determine if it is consteval.  */
> -      if (!concept_check_p (t))
> -	{
> -	  tree x = t;
> -	  if (TREE_CODE (x) == TARGET_EXPR)
> -	    x = TARGET_EXPR_INITIAL (x);
> -	  tree fndecl = cp_get_callee_fndecl_nofold (x);
> -	  if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
> -	    is_consteval = true;
> -	}
> +      tree x = t;
> +      if (TREE_CODE (x) == TARGET_EXPR)
> +	x = TARGET_EXPR_INITIAL (x);
> +      tree fndecl = cp_get_callee_fndecl_nofold (x);
> +      if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
> +	is_consteval = true;
>       }
>     if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
>       {
> diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
> index 0c589eeaaec..003e68f1ea7 100644
> --- a/gcc/cp/cp-gimplify.cc
> +++ b/gcc/cp/cp-gimplify.cc
> @@ -2092,15 +2092,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
>         break;
>   
>       case CALL_EXPR:
> -      /* Evaluate function concept checks instead of treating them as
> -	 normal functions.  */
> -      if (concept_check_p (stmt))
> -	{
> -	  *stmt_p = evaluate_concept_check (stmt);
> -	  * walk_subtrees = 0;
> -	  break;
> -	}
> -
>         if (!wtd->no_sanitize_p
>   	  && sanitize_flags_p ((SANITIZE_NULL
>   				| SANITIZE_ALIGNMENT | SANITIZE_VPTR)))
> diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc
> index 3c69ab69502..0231bd2507d 100644
> --- a/gcc/cp/except.cc
> +++ b/gcc/cp/except.cc
> @@ -1074,8 +1074,6 @@ check_noexcept_r (tree *tp, int *walk_subtrees, void *)
>   
>            We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */
>         tree fn = cp_get_callee (t);
> -      if (concept_check_p (fn))
> -	return NULL_TREE;
>         tree type = TREE_TYPE (fn);
>         gcc_assert (INDIRECT_TYPE_P (type));
>         type = TREE_TYPE (type);
> 
> base-commit: 180625ae72b3f733813a360fae4f0d6ce79eccdc
diff mbox series

Patch

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 8d994f0ee53..b0adbb9036d 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -2797,10 +2797,6 @@  cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
 			  value_cat lval,
 			  bool *non_constant_p, bool *overflow_p)
 {
-  /* Handle concept checks separately.  */
-  if (concept_check_p (t))
-    return evaluate_concept_check (t);
-
   location_t loc = cp_expr_loc_or_input_loc (t);
   tree fun = get_function_named_in_call (t);
   constexpr_call new_call
@@ -8774,16 +8770,12 @@  cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
 	       || TREE_CODE (t) == AGGR_INIT_EXPR
 	       || TREE_CODE (t) == TARGET_EXPR))
     {
-      /* For non-concept checks, determine if it is consteval.  */
-      if (!concept_check_p (t))
-	{
-	  tree x = t;
-	  if (TREE_CODE (x) == TARGET_EXPR)
-	    x = TARGET_EXPR_INITIAL (x);
-	  tree fndecl = cp_get_callee_fndecl_nofold (x);
-	  if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
-	    is_consteval = true;
-	}
+      tree x = t;
+      if (TREE_CODE (x) == TARGET_EXPR)
+	x = TARGET_EXPR_INITIAL (x);
+      tree fndecl = cp_get_callee_fndecl_nofold (x);
+      if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
+	is_consteval = true;
     }
   if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
     {
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 0c589eeaaec..003e68f1ea7 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -2092,15 +2092,6 @@  cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
       break;
 
     case CALL_EXPR:
-      /* Evaluate function concept checks instead of treating them as
-	 normal functions.  */
-      if (concept_check_p (stmt))
-	{
-	  *stmt_p = evaluate_concept_check (stmt);
-	  * walk_subtrees = 0;
-	  break;
-	}
-
       if (!wtd->no_sanitize_p
 	  && sanitize_flags_p ((SANITIZE_NULL
 				| SANITIZE_ALIGNMENT | SANITIZE_VPTR)))
diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc
index 3c69ab69502..0231bd2507d 100644
--- a/gcc/cp/except.cc
+++ b/gcc/cp/except.cc
@@ -1074,8 +1074,6 @@  check_noexcept_r (tree *tp, int *walk_subtrees, void *)
 
          We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */
       tree fn = cp_get_callee (t);
-      if (concept_check_p (fn))
-	return NULL_TREE;
       tree type = TREE_TYPE (fn);
       gcc_assert (INDIRECT_TYPE_P (type));
       type = TREE_TYPE (type);