aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-06-27 19:39:05 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-06-27 19:39:05 +0000
commitacea808abbb527518f052dba0abe0adada6e2d52 (patch)
tree9d5ba83f8740fcb836e8a5b32f4f7e0b745a204c /gcc
parent705037247447f44826bd6fc2c777c69237fcef39 (diff)
downloadgcc-acea808abbb527518f052dba0abe0adada6e2d52.zip
gcc-acea808abbb527518f052dba0abe0adada6e2d52.tar.gz
gcc-acea808abbb527518f052dba0abe0adada6e2d52.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c55
2 files changed, 22 insertions, 36 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bd22319..b5c09ac 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
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 ...
(CLASSTYPE_DESTRUCTOR): ... this.
* class.c (accessible_nvdtor_p,
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c724e27..957d229 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12277,22 +12277,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
case FUNCTION_DECL:
{
- tree ctx;
- tree argvec = NULL_TREE;
- tree *friends;
- tree gen_tmpl;
- tree type;
- int member;
- int args_depth;
- int parms_depth;
+ tree gen_tmpl, argvec;
/* Nobody should be tsubst'ing into non-template functions. */
gcc_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE);
if (TREE_CODE (DECL_TI_TEMPLATE (t)) == TEMPLATE_DECL)
{
- tree spec;
-
/* If T is not dependent, just return it. */
if (!uses_template_parms (DECL_TI_ARGS (t)))
RETURN (t);
@@ -12310,9 +12301,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
/* Check to see if we already have this specialization. */
hash = hash_tmpl_and_args (gen_tmpl, argvec);
- spec = retrieve_specialization (gen_tmpl, argvec, hash);
-
- if (spec)
+ if (tree spec = retrieve_specialization (gen_tmpl, argvec, hash))
{
r = spec;
break;
@@ -12350,11 +12339,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
which we can spot because the pattern will be a
specialization in this case. */
- args_depth = TMPL_ARGS_DEPTH (args);
- parms_depth =
+ int args_depth = TMPL_ARGS_DEPTH (args);
+ int parms_depth =
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);
}
else
@@ -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
determine_specialization. */
gen_tmpl = NULL_TREE;
+ argvec = NULL_TREE;
}
- if (DECL_CLASS_SCOPE_P (t))
- {
- if (DECL_NAME (t) == constructor_name (DECL_CONTEXT (t)))
- member = 2;
- else
- member = 1;
- ctx = tsubst_aggr_type (DECL_CONTEXT (t), args,
- complain, t, /*entering_scope=*/1);
- }
- else
- {
- member = 0;
- ctx = DECL_CONTEXT (t);
- }
- type = tsubst (TREE_TYPE (t), args, complain|tf_fndecl_type, in_decl);
+ tree ctx = DECL_CONTEXT (t);
+ bool member = ctx && TYPE_P (ctx);
+
+ if (member)
+ ctx = tsubst_aggr_type (ctx, args,
+ complain, t, /*entering_scope=*/1);
+
+ tree type = tsubst (TREE_TYPE (t), args,
+ complain | tf_fndecl_type, in_decl);
if (type == error_mark_node)
RETURN (error_mark_node);
@@ -12507,14 +12491,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
DECL_TEMPLATE_INFO (r) = NULL_TREE;
/* Copy the list of befriending classes. */
- for (friends = &DECL_BEFRIENDING_CLASSES (r);
+ for (tree *friends = &DECL_BEFRIENDING_CLASSES (r);
*friends;
friends = &TREE_CHAIN (*friends))
{
*friends = copy_node (*friends);
- TREE_VALUE (*friends) = tsubst (TREE_VALUE (*friends),
- args, complain,
- in_decl);
+ TREE_VALUE (*friends)
+ = tsubst (TREE_VALUE (*friends), args, complain, in_decl);
}
if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r))