diff mbox series

c++: simplify TEMPLATE_TEMPLATE_PARM hashing

Message ID 20230602142928.1793231-1-ppalka@redhat.com
State New
Headers show
Series c++: simplify TEMPLATE_TEMPLATE_PARM hashing | expand

Commit Message

Patrick Palka June 2, 2023, 2:29 p.m. UTC
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk?

-- >8 --

r10-7815-gaa576f2a860c82 added special hashing for TEMPLATE_TEMPLATE_PARM
since non-lowered ttps had TYPE_CANONICAL but level lowered ttps did not.
But this is no longer the case ever since r13-737-gd0ef9e06197d14 made
us set TYPE_CANONICAL for level lowered ttps as well.  So this special
hashing is now unnecessary, and we can fall back to using TYPE_CANONICAL.

gcc/cp/ChangeLog:

	* pt.cc (iterative_hash_template_arg): Don't hash
	TEMPLATE_TEMPLATE_PARM specially.
---
 gcc/cp/pt.cc | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Jason Merrill June 2, 2023, 4:30 p.m. UTC | #1
On 6/2/23 10:29, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk?

OK.

> -- >8 --
> 
> r10-7815-gaa576f2a860c82 added special hashing for TEMPLATE_TEMPLATE_PARM
> since non-lowered ttps had TYPE_CANONICAL but level lowered ttps did not.
> But this is no longer the case ever since r13-737-gd0ef9e06197d14 made
> us set TYPE_CANONICAL for level lowered ttps as well.  So this special
> hashing is now unnecessary, and we can fall back to using TYPE_CANONICAL.
> 
> gcc/cp/ChangeLog:
> 
> 	* pt.cc (iterative_hash_template_arg): Don't hash
> 	TEMPLATE_TEMPLATE_PARM specially.
> ---
>   gcc/cp/pt.cc | 13 +------------
>   1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 688a87a4bd3..7c2a5647665 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -1879,19 +1879,8 @@ iterative_hash_template_arg (tree arg, hashval_t val)
>   	  return hash_tmpl_and_args (TI_TEMPLATE (ti), TI_ARGS (ti));
>   	}
>   
> -      switch (TREE_CODE (arg))
> +      switch (code)
>   	{
> -	case TEMPLATE_TEMPLATE_PARM:
> -	  {
> -	    tree tpi = TEMPLATE_TYPE_PARM_INDEX (arg);
> -
> -	    /* Do not recurse with TPI directly, as that is unbounded
> -	       recursion.  */
> -	    val = iterative_hash_object (TEMPLATE_PARM_LEVEL (tpi), val);
> -	    val = iterative_hash_object (TEMPLATE_PARM_IDX (tpi), val);
> -	  }
> -	  break;
> -
>   	case  DECLTYPE_TYPE:
>   	  val = iterative_hash_template_arg (DECLTYPE_TYPE_EXPR (arg), val);
>   	  break;
diff mbox series

Patch

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 688a87a4bd3..7c2a5647665 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -1879,19 +1879,8 @@  iterative_hash_template_arg (tree arg, hashval_t val)
 	  return hash_tmpl_and_args (TI_TEMPLATE (ti), TI_ARGS (ti));
 	}
 
-      switch (TREE_CODE (arg))
+      switch (code)
 	{
-	case TEMPLATE_TEMPLATE_PARM:
-	  {
-	    tree tpi = TEMPLATE_TYPE_PARM_INDEX (arg);
-
-	    /* Do not recurse with TPI directly, as that is unbounded
-	       recursion.  */
-	    val = iterative_hash_object (TEMPLATE_PARM_LEVEL (tpi), val);
-	    val = iterative_hash_object (TEMPLATE_PARM_IDX (tpi), val);
-	  }
-	  break;
-
 	case  DECLTYPE_TYPE:
 	  val = iterative_hash_template_arg (DECLTYPE_TYPE_EXPR (arg), val);
 	  break;