Commit acea808a by Nathan Sidwell Committed by Nathan Sidwell

pt.c (tsubst_decl <FUNCTION_DECL>): Move var decls to initialization point.

	* pt.c (tsubst_decl <FUNCTION_DECL>): Move var decls to
	initialization point.  Don't unnecessarily check for ctor name.

From-SVN: r249709
parent 70503724
2017-06-27 Nathan Sidwell <nathan@acm.org> 2017-06-27 Nathan Sidwell <nathan@acm.org>
* pt.c (tsubst_decl <FUNCTION_DECL>): Move var decls to
initialization point. Don't unnecessarily check for ctor name.
* cp-tree.h (CLASSTYPE_DESTRUCTORS): Rename to ... * cp-tree.h (CLASSTYPE_DESTRUCTORS): Rename to ...
(CLASSTYPE_DESTRUCTOR): ... this. (CLASSTYPE_DESTRUCTOR): ... this.
* class.c (accessible_nvdtor_p, * class.c (accessible_nvdtor_p,
......
...@@ -12277,22 +12277,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12277,22 +12277,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
case FUNCTION_DECL: case FUNCTION_DECL:
{ {
tree ctx; tree gen_tmpl, argvec;
tree argvec = NULL_TREE;
tree *friends;
tree gen_tmpl;
tree type;
int member;
int args_depth;
int parms_depth;
/* Nobody should be tsubst'ing into non-template functions. */ /* Nobody should be tsubst'ing into non-template functions. */
gcc_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE); gcc_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE);
if (TREE_CODE (DECL_TI_TEMPLATE (t)) == TEMPLATE_DECL) if (TREE_CODE (DECL_TI_TEMPLATE (t)) == TEMPLATE_DECL)
{ {
tree spec;
/* If T is not dependent, just return it. */ /* If T is not dependent, just return it. */
if (!uses_template_parms (DECL_TI_ARGS (t))) if (!uses_template_parms (DECL_TI_ARGS (t)))
RETURN (t); RETURN (t);
...@@ -12310,9 +12301,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12310,9 +12301,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
/* Check to see if we already have this specialization. */ /* Check to see if we already have this specialization. */
hash = hash_tmpl_and_args (gen_tmpl, argvec); hash = hash_tmpl_and_args (gen_tmpl, argvec);
spec = retrieve_specialization (gen_tmpl, argvec, hash); if (tree spec = retrieve_specialization (gen_tmpl, argvec, hash))
if (spec)
{ {
r = spec; r = spec;
break; break;
...@@ -12350,11 +12339,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12350,11 +12339,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
which we can spot because the pattern will be a which we can spot because the pattern will be a
specialization in this case. */ specialization in this case. */
args_depth = TMPL_ARGS_DEPTH (args); int args_depth = TMPL_ARGS_DEPTH (args);
parms_depth = int parms_depth =
TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (DECL_TI_TEMPLATE (t))); TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (DECL_TI_TEMPLATE (t)));
if (args_depth > parms_depth
&& !DECL_TEMPLATE_SPECIALIZATION (t)) if (args_depth > parms_depth && !DECL_TEMPLATE_SPECIALIZATION (t))
args = get_innermost_template_args (args, parms_depth); args = get_innermost_template_args (args, parms_depth);
} }
else else
...@@ -12371,23 +12360,18 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12371,23 +12360,18 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
new decl (R) with appropriate types so that we can call new decl (R) with appropriate types so that we can call
determine_specialization. */ determine_specialization. */
gen_tmpl = NULL_TREE; gen_tmpl = NULL_TREE;
argvec = NULL_TREE;
} }
if (DECL_CLASS_SCOPE_P (t)) tree ctx = DECL_CONTEXT (t);
{ bool member = ctx && TYPE_P (ctx);
if (DECL_NAME (t) == constructor_name (DECL_CONTEXT (t)))
member = 2; if (member)
else ctx = tsubst_aggr_type (ctx, args,
member = 1; complain, t, /*entering_scope=*/1);
ctx = tsubst_aggr_type (DECL_CONTEXT (t), args,
complain, t, /*entering_scope=*/1); tree type = tsubst (TREE_TYPE (t), args,
} complain | tf_fndecl_type, in_decl);
else
{
member = 0;
ctx = DECL_CONTEXT (t);
}
type = tsubst (TREE_TYPE (t), args, complain|tf_fndecl_type, in_decl);
if (type == error_mark_node) if (type == error_mark_node)
RETURN (error_mark_node); RETURN (error_mark_node);
...@@ -12507,14 +12491,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12507,14 +12491,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
DECL_TEMPLATE_INFO (r) = NULL_TREE; DECL_TEMPLATE_INFO (r) = NULL_TREE;
/* Copy the list of befriending classes. */ /* Copy the list of befriending classes. */
for (friends = &DECL_BEFRIENDING_CLASSES (r); for (tree *friends = &DECL_BEFRIENDING_CLASSES (r);
*friends; *friends;
friends = &TREE_CHAIN (*friends)) friends = &TREE_CHAIN (*friends))
{ {
*friends = copy_node (*friends); *friends = copy_node (*friends);
TREE_VALUE (*friends) = tsubst (TREE_VALUE (*friends), TREE_VALUE (*friends)
args, complain, = tsubst (TREE_VALUE (*friends), args, complain, in_decl);
in_decl);
} }
if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r)) if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment