diff mbox series

c++: squash cp_build_qualified_type/_real

Message ID 20220531171308.131365-1-ppalka@redhat.com
State New
Headers show
Series c++: squash cp_build_qualified_type/_real | expand

Commit Message

Patrick Palka May 31, 2022, 5:13 p.m. UTC
This replaces the two differently named versions of the same function
with a single function using a default function argument.

Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
for trunk?

gcc/cp/ChangeLog:

	* cp-tree.h (cp_build_qualified_type_real): Rename to ...
	(cp_build_qualified_type): ... this.  Give its last parameter
	a default argument.  Remove macro of the same name.
	* decl.cc (grokdeclarator): Adjust accordingly.
	* pt.cc (tsubst_aggr_type): Likewise.
	(rebuild_function_or_method_type): Likewise.
	(tsubst): Likewise.
	(maybe_dependent_member_ref): Likewise.
	(unify): Likewise.
	* tree.cc (cp_build_qualified_type_real): Rename to ...
	(cp_build_qualified_type): ... this.  Adjust accordingly.
---
 gcc/cp/cp-tree.h |  5 ++---
 gcc/cp/decl.cc   |  2 +-
 gcc/cp/pt.cc     | 52 ++++++++++++++++++++++++------------------------
 gcc/cp/tree.cc   | 11 ++++------
 4 files changed, 33 insertions(+), 37 deletions(-)

Comments

Jason Merrill May 31, 2022, 7:05 p.m. UTC | #1
On 5/31/22 13:13, Patrick Palka wrote:
> This replaces the two differently named versions of the same function
> with a single function using a default function argument.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
> for trunk?

OK.

> gcc/cp/ChangeLog:
> 
> 	* cp-tree.h (cp_build_qualified_type_real): Rename to ...
> 	(cp_build_qualified_type): ... this.  Give its last parameter
> 	a default argument.  Remove macro of the same name.
> 	* decl.cc (grokdeclarator): Adjust accordingly.
> 	* pt.cc (tsubst_aggr_type): Likewise.
> 	(rebuild_function_or_method_type): Likewise.
> 	(tsubst): Likewise.
> 	(maybe_dependent_member_ref): Likewise.
> 	(unify): Likewise.
> 	* tree.cc (cp_build_qualified_type_real): Rename to ...
> 	(cp_build_qualified_type): ... this.  Adjust accordingly.
> ---
>   gcc/cp/cp-tree.h |  5 ++---
>   gcc/cp/decl.cc   |  2 +-
>   gcc/cp/pt.cc     | 52 ++++++++++++++++++++++++------------------------
>   gcc/cp/tree.cc   | 11 ++++------
>   4 files changed, 33 insertions(+), 37 deletions(-)
> 
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index da8898155e0..cc13809f38a 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -7877,9 +7877,8 @@ extern tree make_ptrmem_cst			(tree, tree);
>   extern tree cp_build_type_attribute_variant     (tree, tree);
>   extern tree cp_build_reference_type		(tree, bool);
>   extern tree move				(tree);
> -extern tree cp_build_qualified_type_real	(tree, int, tsubst_flags_t);
> -#define cp_build_qualified_type(TYPE, QUALS) \
> -  cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
> +extern tree cp_build_qualified_type		(tree, int,
> +						 tsubst_flags_t = tf_warning_or_error);
>   extern bool cv_qualified_p			(const_tree);
>   extern tree cv_unqualified			(tree);
>   extern special_function_kind special_function_p (const_tree);
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index 663a72fae15..e0d397d5a07 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -12375,7 +12375,7 @@ grokdeclarator (const cp_declarator *declarator,
>       type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
>   
>     type_quals |= cp_type_quals (type);
> -  type = cp_build_qualified_type_real
> +  type = cp_build_qualified_type
>       (type, type_quals, ((((typedef_decl && !DECL_ARTIFICIAL (typedef_decl))
>   			  || declspecs->decltype_p)
>   			 ? tf_ignore_bad_quals : 0) | tf_warning_or_error));
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 4a3f38b1f5a..759f119abc2 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -13767,7 +13767,7 @@ tsubst_aggr_type (tree t,
>   	    {
>   	      r = lookup_template_class (t, argvec, in_decl, context,
>   					 entering_scope, complain);
> -	      r = cp_build_qualified_type_real (r, cp_type_quals (t), complain);
> +	      r = cp_build_qualified_type (r, cp_type_quals (t), complain);
>   	    }
>   
>   	  return r;
> @@ -13963,7 +13963,7 @@ rebuild_function_or_method_type (tree t, tree return_type, tree arg_types,
>       {
>         tree r = TREE_TYPE (TREE_VALUE (arg_types));
>         /* Don't pick up extra function qualifiers from the basetype.  */
> -      r = cp_build_qualified_type_real (r, type_memfn_quals (t), complain);
> +      r = cp_build_qualified_type (r, type_memfn_quals (t), complain);
>         if (! MAYBE_CLASS_TYPE_P (r))
>   	{
>   	  /* [temp.deduct]
> @@ -15651,7 +15651,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>         if (r)
>   	{
>   	  r = TREE_TYPE (r);
> -	  r = cp_build_qualified_type_real
> +	  r = cp_build_qualified_type
>   	    (r, cp_type_quals (t) | cp_type_quals (r),
>   	     complain | tf_ignore_bad_quals);
>   	  return r;
> @@ -15661,8 +15661,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	  /* We don't have an instantiation yet, so drop the typedef.  */
>   	  int quals = cp_type_quals (t);
>   	  t = DECL_ORIGINAL_TYPE (decl);
> -	  t = cp_build_qualified_type_real (t, quals,
> -					    complain | tf_ignore_bad_quals);
> +	  t = cp_build_qualified_type (t, quals,
> +				       complain | tf_ignore_bad_quals);
>   	}
>       }
>   
> @@ -15809,7 +15809,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   
>   		quals = cp_type_quals (arg) | cp_type_quals (t);
>   
> -		return cp_build_qualified_type_real
> +		return cp_build_qualified_type
>   		  (arg, quals, complain | tf_ignore_bad_quals);
>   	      }
>   	    else if (code == BOUND_TEMPLATE_TEMPLATE_PARM)
> @@ -15874,7 +15874,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   					   DECL_CONTEXT (arg),
>   					    /*entering_scope=*/0,
>   					   complain);
> -		return cp_build_qualified_type_real
> +		return cp_build_qualified_type
>   		  (r, cp_type_quals (t) | cp_type_quals (r), complain);
>   	      }
>   	    else if (code == TEMPLATE_TEMPLATE_PARM)
> @@ -15909,7 +15909,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	    if (cp_type_quals (t))
>   	      {
>   		r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl);
> -		r = cp_build_qualified_type_real
> +		r = cp_build_qualified_type
>   		  (r, cp_type_quals (t),
>   		   complain | (code == TEMPLATE_TYPE_PARM
>   			       ? tf_ignore_bad_quals : 0));
> @@ -16079,7 +16079,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	       TYPE_REF_IS_RVALUE (t) && TYPE_REF_IS_RVALUE (type));
>   	else
>   	  r = cp_build_reference_type (type, TYPE_REF_IS_RVALUE (t));
> -	r = cp_build_qualified_type_real (r, cp_type_quals (t), complain);
> +	r = cp_build_qualified_type (r, cp_type_quals (t), complain);
>   
>   	if (r != error_mark_node)
>   	  /* Will this ever be needed for TYPE_..._TO values?  */
> @@ -16125,13 +16125,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	      = build_memfn_type (type, r, type_memfn_quals (type),
>   				  type_memfn_rqual (type));
>   	    memptr = build_ptrmemfunc_type (build_pointer_type (method_type));
> -	    return cp_build_qualified_type_real (memptr, cp_type_quals (t),
> -						 complain);
> +	    return cp_build_qualified_type (memptr, cp_type_quals (t),
> +					    complain);
>   	  }
>   	else
> -	  return cp_build_qualified_type_real (build_ptrmem_type (r, type),
> -					       cp_type_quals (t),
> -					       complain);
> +	  return cp_build_qualified_type (build_ptrmem_type (r, type),
> +					  cp_type_quals (t),
> +					  complain);
>         }
>       case FUNCTION_TYPE:
>       case METHOD_TYPE:
> @@ -16282,7 +16282,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	      }
>   	  }
>   
> -	return cp_build_qualified_type_real
> +	return cp_build_qualified_type
>   	  (f, cp_type_quals (f) | cp_type_quals (t), complain);
>         }
>   
> @@ -16316,10 +16316,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	--c_inhibit_evaluation_warnings;
>   
>   	type = finish_typeof (type);
> -	return cp_build_qualified_type_real (type,
> -					     cp_type_quals (t)
> -					     | cp_type_quals (type),
> -					     complain);
> +	return cp_build_qualified_type (type,
> +					cp_type_quals (t)
> +					| cp_type_quals (type),
> +					complain);
>         }
>   
>       case DECLTYPE_TYPE:
> @@ -16355,10 +16355,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>   	      id = false;
>   	    type = finish_decltype_type (type, id, complain);
>   	  }
> -	return cp_build_qualified_type_real (type,
> -					     cp_type_quals (t)
> -					     | cp_type_quals (type),
> -					     complain | tf_ignore_bad_quals);
> +	return cp_build_qualified_type (type,
> +					cp_type_quals (t)
> +					| cp_type_quals (type),
> +					complain | tf_ignore_bad_quals);
>         }
>   
>       case UNDERLYING_TYPE:
> @@ -16858,8 +16858,8 @@ maybe_dependent_member_ref (tree t, tree args, tsubst_flags_t complain,
>   	decl = maybe_dependent_member_ref (decl, args, complain, in_decl);
>         if (!decl)
>   	return NULL_TREE;
> -      return cp_build_qualified_type_real (TREE_TYPE (decl), cp_type_quals (t),
> -					   complain);
> +      return cp_build_qualified_type (TREE_TYPE (decl), cp_type_quals (t),
> +				      complain);
>       }
>   
>     tree name = DECL_NAME (t);
> @@ -24231,7 +24231,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
>   
>   	  /* Consider the case where ARG is `const volatile int' and
>   	     PARM is `const T'.  Then, T should be `volatile int'.  */
> -	  arg = cp_build_qualified_type_real
> +	  arg = cp_build_qualified_type
>   	    (arg, cp_type_quals (arg) & ~cp_type_quals (parm), tf_none);
>   	  if (arg == error_mark_node)
>   	    return unify_invalid (explain_p);
> diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> index 09162795801..2b9cb7e1c7b 100644
> --- a/gcc/cp/tree.cc
> +++ b/gcc/cp/tree.cc
> @@ -1359,9 +1359,8 @@ c_build_qualified_type (tree type, int type_quals, tree /* orig_qual_type */,
>      in a similar manner for restricting non-pointer types.  */
>   
>   tree
> -cp_build_qualified_type_real (tree type,
> -			      int type_quals,
> -			      tsubst_flags_t complain)
> +cp_build_qualified_type (tree type, int type_quals,
> +			 tsubst_flags_t complain /* = tf_warning_or_error */)
>   {
>     tree result;
>     int bad_quals = TYPE_UNQUALIFIED;
> @@ -1378,9 +1377,7 @@ cp_build_qualified_type_real (tree type,
>   	 type.  Obtain the appropriately qualified element type.  */
>         tree t;
>         tree element_type
> -	= cp_build_qualified_type_real (TREE_TYPE (type),
> -					type_quals,
> -					complain);
> +	= cp_build_qualified_type (TREE_TYPE (type), type_quals, complain);
>   
>         if (element_type == error_mark_node)
>   	return error_mark_node;
> @@ -1431,7 +1428,7 @@ cp_build_qualified_type_real (tree type,
>       {
>         tree t = PACK_EXPANSION_PATTERN (type);
>   
> -      t = cp_build_qualified_type_real (t, type_quals, complain);
> +      t = cp_build_qualified_type (t, type_quals, complain);
>         return make_pack_expansion (t, complain);
>       }
>
diff mbox series

Patch

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index da8898155e0..cc13809f38a 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7877,9 +7877,8 @@  extern tree make_ptrmem_cst			(tree, tree);
 extern tree cp_build_type_attribute_variant     (tree, tree);
 extern tree cp_build_reference_type		(tree, bool);
 extern tree move				(tree);
-extern tree cp_build_qualified_type_real	(tree, int, tsubst_flags_t);
-#define cp_build_qualified_type(TYPE, QUALS) \
-  cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
+extern tree cp_build_qualified_type		(tree, int,
+						 tsubst_flags_t = tf_warning_or_error);
 extern bool cv_qualified_p			(const_tree);
 extern tree cv_unqualified			(tree);
 extern special_function_kind special_function_p (const_tree);
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 663a72fae15..e0d397d5a07 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -12375,7 +12375,7 @@  grokdeclarator (const cp_declarator *declarator,
     type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
 
   type_quals |= cp_type_quals (type);
-  type = cp_build_qualified_type_real
+  type = cp_build_qualified_type
     (type, type_quals, ((((typedef_decl && !DECL_ARTIFICIAL (typedef_decl))
 			  || declspecs->decltype_p)
 			 ? tf_ignore_bad_quals : 0) | tf_warning_or_error));
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4a3f38b1f5a..759f119abc2 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -13767,7 +13767,7 @@  tsubst_aggr_type (tree t,
 	    {
 	      r = lookup_template_class (t, argvec, in_decl, context,
 					 entering_scope, complain);
-	      r = cp_build_qualified_type_real (r, cp_type_quals (t), complain);
+	      r = cp_build_qualified_type (r, cp_type_quals (t), complain);
 	    }
 
 	  return r;
@@ -13963,7 +13963,7 @@  rebuild_function_or_method_type (tree t, tree return_type, tree arg_types,
     {
       tree r = TREE_TYPE (TREE_VALUE (arg_types));
       /* Don't pick up extra function qualifiers from the basetype.  */
-      r = cp_build_qualified_type_real (r, type_memfn_quals (t), complain);
+      r = cp_build_qualified_type (r, type_memfn_quals (t), complain);
       if (! MAYBE_CLASS_TYPE_P (r))
 	{
 	  /* [temp.deduct]
@@ -15651,7 +15651,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       if (r)
 	{
 	  r = TREE_TYPE (r);
-	  r = cp_build_qualified_type_real
+	  r = cp_build_qualified_type
 	    (r, cp_type_quals (t) | cp_type_quals (r),
 	     complain | tf_ignore_bad_quals);
 	  return r;
@@ -15661,8 +15661,8 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	  /* We don't have an instantiation yet, so drop the typedef.  */
 	  int quals = cp_type_quals (t);
 	  t = DECL_ORIGINAL_TYPE (decl);
-	  t = cp_build_qualified_type_real (t, quals,
-					    complain | tf_ignore_bad_quals);
+	  t = cp_build_qualified_type (t, quals,
+				       complain | tf_ignore_bad_quals);
 	}
     }
 
@@ -15809,7 +15809,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
 		quals = cp_type_quals (arg) | cp_type_quals (t);
 
-		return cp_build_qualified_type_real
+		return cp_build_qualified_type
 		  (arg, quals, complain | tf_ignore_bad_quals);
 	      }
 	    else if (code == BOUND_TEMPLATE_TEMPLATE_PARM)
@@ -15874,7 +15874,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 					   DECL_CONTEXT (arg),
 					    /*entering_scope=*/0,
 					   complain);
-		return cp_build_qualified_type_real
+		return cp_build_qualified_type
 		  (r, cp_type_quals (t) | cp_type_quals (r), complain);
 	      }
 	    else if (code == TEMPLATE_TEMPLATE_PARM)
@@ -15909,7 +15909,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	    if (cp_type_quals (t))
 	      {
 		r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl);
-		r = cp_build_qualified_type_real
+		r = cp_build_qualified_type
 		  (r, cp_type_quals (t),
 		   complain | (code == TEMPLATE_TYPE_PARM
 			       ? tf_ignore_bad_quals : 0));
@@ -16079,7 +16079,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	       TYPE_REF_IS_RVALUE (t) && TYPE_REF_IS_RVALUE (type));
 	else
 	  r = cp_build_reference_type (type, TYPE_REF_IS_RVALUE (t));
-	r = cp_build_qualified_type_real (r, cp_type_quals (t), complain);
+	r = cp_build_qualified_type (r, cp_type_quals (t), complain);
 
 	if (r != error_mark_node)
 	  /* Will this ever be needed for TYPE_..._TO values?  */
@@ -16125,13 +16125,13 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	      = build_memfn_type (type, r, type_memfn_quals (type),
 				  type_memfn_rqual (type));
 	    memptr = build_ptrmemfunc_type (build_pointer_type (method_type));
-	    return cp_build_qualified_type_real (memptr, cp_type_quals (t),
-						 complain);
+	    return cp_build_qualified_type (memptr, cp_type_quals (t),
+					    complain);
 	  }
 	else
-	  return cp_build_qualified_type_real (build_ptrmem_type (r, type),
-					       cp_type_quals (t),
-					       complain);
+	  return cp_build_qualified_type (build_ptrmem_type (r, type),
+					  cp_type_quals (t),
+					  complain);
       }
     case FUNCTION_TYPE:
     case METHOD_TYPE:
@@ -16282,7 +16282,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	      }
 	  }
 
-	return cp_build_qualified_type_real
+	return cp_build_qualified_type
 	  (f, cp_type_quals (f) | cp_type_quals (t), complain);
       }
 
@@ -16316,10 +16316,10 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	--c_inhibit_evaluation_warnings;
 
 	type = finish_typeof (type);
-	return cp_build_qualified_type_real (type,
-					     cp_type_quals (t)
-					     | cp_type_quals (type),
-					     complain);
+	return cp_build_qualified_type (type,
+					cp_type_quals (t)
+					| cp_type_quals (type),
+					complain);
       }
 
     case DECLTYPE_TYPE:
@@ -16355,10 +16355,10 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	      id = false;
 	    type = finish_decltype_type (type, id, complain);
 	  }
-	return cp_build_qualified_type_real (type,
-					     cp_type_quals (t)
-					     | cp_type_quals (type),
-					     complain | tf_ignore_bad_quals);
+	return cp_build_qualified_type (type,
+					cp_type_quals (t)
+					| cp_type_quals (type),
+					complain | tf_ignore_bad_quals);
       }
 
     case UNDERLYING_TYPE:
@@ -16858,8 +16858,8 @@  maybe_dependent_member_ref (tree t, tree args, tsubst_flags_t complain,
 	decl = maybe_dependent_member_ref (decl, args, complain, in_decl);
       if (!decl)
 	return NULL_TREE;
-      return cp_build_qualified_type_real (TREE_TYPE (decl), cp_type_quals (t),
-					   complain);
+      return cp_build_qualified_type (TREE_TYPE (decl), cp_type_quals (t),
+				      complain);
     }
 
   tree name = DECL_NAME (t);
@@ -24231,7 +24231,7 @@  unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 
 	  /* Consider the case where ARG is `const volatile int' and
 	     PARM is `const T'.  Then, T should be `volatile int'.  */
-	  arg = cp_build_qualified_type_real
+	  arg = cp_build_qualified_type
 	    (arg, cp_type_quals (arg) & ~cp_type_quals (parm), tf_none);
 	  if (arg == error_mark_node)
 	    return unify_invalid (explain_p);
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 09162795801..2b9cb7e1c7b 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1359,9 +1359,8 @@  c_build_qualified_type (tree type, int type_quals, tree /* orig_qual_type */,
    in a similar manner for restricting non-pointer types.  */
 
 tree
-cp_build_qualified_type_real (tree type,
-			      int type_quals,
-			      tsubst_flags_t complain)
+cp_build_qualified_type (tree type, int type_quals,
+			 tsubst_flags_t complain /* = tf_warning_or_error */)
 {
   tree result;
   int bad_quals = TYPE_UNQUALIFIED;
@@ -1378,9 +1377,7 @@  cp_build_qualified_type_real (tree type,
 	 type.  Obtain the appropriately qualified element type.  */
       tree t;
       tree element_type
-	= cp_build_qualified_type_real (TREE_TYPE (type),
-					type_quals,
-					complain);
+	= cp_build_qualified_type (TREE_TYPE (type), type_quals, complain);
 
       if (element_type == error_mark_node)
 	return error_mark_node;
@@ -1431,7 +1428,7 @@  cp_build_qualified_type_real (tree type,
     {
       tree t = PACK_EXPANSION_PATTERN (type);
 
-      t = cp_build_qualified_type_real (t, type_quals, complain);
+      t = cp_build_qualified_type (t, type_quals, complain);
       return make_pack_expansion (t, complain);
     }