diff mbox

Small C++ PATCH to clean up non-type template parameter handling

Message ID 563CC58B.6050203@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 6, 2015, 3:21 p.m. UTC
The old code here laments not being able to reuse the CONST_DECL created 
by process_template_parm, but we can get to it from the TEMPLATE_PARM_INDEX.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 02af5bca9bd6dbd3080bef614e411c56303d3c66
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Nov 5 16:20:12 2015 -0500

    	* pt.c (push_inline_template_parms_recursive): Don't recreate the
    	CONST_DECL.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 45eda3a..bfea8e2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -441,21 +441,8 @@  push_inline_template_parms_recursive (tree parmlist, int levels)
 	  break;
 
 	case PARM_DECL:
-	  {
-	    /* Make a CONST_DECL as is done in process_template_parm.
-	       It is ugly that we recreate this here; the original
-	       version built in process_template_parm is no longer
-	       available.  */
-	    tree decl = build_decl (DECL_SOURCE_LOCATION (parm),
-				    CONST_DECL, DECL_NAME (parm),
-				    TREE_TYPE (parm));
-	    DECL_ARTIFICIAL (decl) = 1;
-	    TREE_CONSTANT (decl) = 1;
-	    TREE_READONLY (decl) = 1;
-	    DECL_INITIAL (decl) = DECL_INITIAL (parm);
-	    SET_DECL_TEMPLATE_PARM_P (decl);
-	    pushdecl (decl);
-	  }
+	  /* Push the CONST_DECL.  */
+	  pushdecl (TEMPLATE_PARM_DECL (DECL_INITIAL (parm)));
 	  break;
 
 	default: