Commit 394473ab by Paolo Carlini

pt.c (tsubst): Early declare code = TREE_CODE (t) and use it throughout.

2010-07-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* pt.c (tsubst): Early declare code = TREE_CODE (t) and use it
	throughout.

From-SVN: r161825
parent e4dde839
2010-07-05 Paolo Carlini <paolo.carlini@oracle.com>
* pt.c (tsubst): Early declare code = TREE_CODE (t) and use it
throughout.
2010-07-05 Shujing Zhao <pearly.zhao@oracle.com> 2010-07-05 Shujing Zhao <pearly.zhao@oracle.com>
PR c++/22138 PR c++/22138
......
...@@ -9958,6 +9958,7 @@ tsubst_exception_specification (tree fntype, ...@@ -9958,6 +9958,7 @@ tsubst_exception_specification (tree fntype,
tree tree
tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
{ {
enum tree_code code;
tree type, r; tree type, r;
if (t == NULL_TREE || t == error_mark_node if (t == NULL_TREE || t == error_mark_node
...@@ -9974,7 +9975,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -9974,7 +9975,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (args == NULL_TREE) if (args == NULL_TREE)
return t; return t;
if (TREE_CODE (t) == IDENTIFIER_NODE) code = TREE_CODE (t);
if (code == IDENTIFIER_NODE)
type = IDENTIFIER_TYPE_VALUE (t); type = IDENTIFIER_TYPE_VALUE (t);
else else
type = TREE_TYPE (t); type = TREE_TYPE (t);
...@@ -10017,16 +10020,16 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10017,16 +10020,16 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
} }
if (type if (type
&& TREE_CODE (t) != TYPENAME_TYPE && code != TYPENAME_TYPE
&& TREE_CODE (t) != TEMPLATE_TYPE_PARM && code != TEMPLATE_TYPE_PARM
&& TREE_CODE (t) != IDENTIFIER_NODE && code != IDENTIFIER_NODE
&& TREE_CODE (t) != FUNCTION_TYPE && code != FUNCTION_TYPE
&& TREE_CODE (t) != METHOD_TYPE) && code != METHOD_TYPE)
type = tsubst (type, args, complain, in_decl); type = tsubst (type, args, complain, in_decl);
if (type == error_mark_node) if (type == error_mark_node)
return error_mark_node; return error_mark_node;
switch (TREE_CODE (t)) switch (code)
{ {
case RECORD_TYPE: case RECORD_TYPE:
case UNION_TYPE: case UNION_TYPE:
...@@ -10156,7 +10159,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10156,7 +10159,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
}; */ }; */
return t; return t;
if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) if (code == TEMPLATE_TYPE_PARM)
{ {
int quals; int quals;
gcc_assert (TYPE_P (arg)); gcc_assert (TYPE_P (arg));
...@@ -10166,7 +10169,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10166,7 +10169,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return cp_build_qualified_type_real return cp_build_qualified_type_real
(arg, quals, complain | tf_ignore_bad_quals); (arg, quals, complain | tf_ignore_bad_quals);
} }
else if (TREE_CODE (t) == BOUND_TEMPLATE_TEMPLATE_PARM) else if (code == BOUND_TEMPLATE_TEMPLATE_PARM)
{ {
/* We are processing a type constructed from a /* We are processing a type constructed from a
template template parameter. */ template template parameter. */
...@@ -10205,7 +10208,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10205,7 +10208,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* If we get here, we must have been looking at a parm for a /* If we get here, we must have been looking at a parm for a
more deeply nested template. Make a new version of this more deeply nested template. Make a new version of this
template parameter, but with a lower level. */ template parameter, but with a lower level. */
switch (TREE_CODE (t)) switch (code)
{ {
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
...@@ -10215,7 +10218,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10215,7 +10218,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl); r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl);
r = cp_build_qualified_type_real r = cp_build_qualified_type_real
(r, cp_type_quals (t), (r, cp_type_quals (t),
complain | (TREE_CODE (t) == TEMPLATE_TYPE_PARM complain | (code == TEMPLATE_TYPE_PARM
? tf_ignore_bad_quals : 0)); ? tf_ignore_bad_quals : 0));
} }
else else
...@@ -10243,7 +10246,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10243,7 +10246,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
else else
TYPE_CANONICAL (r) = canonical_type_parameter (r); TYPE_CANONICAL (r) = canonical_type_parameter (r);
if (TREE_CODE (t) == BOUND_TEMPLATE_TEMPLATE_PARM) if (code == BOUND_TEMPLATE_TEMPLATE_PARM)
{ {
tree argvec = tsubst (TYPE_TI_ARGS (t), args, tree argvec = tsubst (TYPE_TI_ARGS (t), args,
complain, in_decl); complain, in_decl);
...@@ -10314,14 +10317,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10314,14 +10317,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case POINTER_TYPE: case POINTER_TYPE:
case REFERENCE_TYPE: case REFERENCE_TYPE:
{ {
enum tree_code code;
if (type == TREE_TYPE (t) && TREE_CODE (type) != METHOD_TYPE) if (type == TREE_TYPE (t) && TREE_CODE (type) != METHOD_TYPE)
return t; return t;
code = TREE_CODE (t);
/* [temp.deduct] /* [temp.deduct]
Type deduction may fail for any of the following Type deduction may fail for any of the following
...@@ -10506,7 +10504,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10506,7 +10504,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return error_mark_node; return error_mark_node;
return fold_build2_loc (input_location, return fold_build2_loc (input_location,
TREE_CODE (t), TREE_TYPE (t), e1, e2); code, TREE_TYPE (t), e1, e2);
} }
case NEGATE_EXPR: case NEGATE_EXPR:
...@@ -10516,7 +10514,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10516,7 +10514,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (e == error_mark_node) if (e == error_mark_node)
return error_mark_node; return error_mark_node;
return fold_build1_loc (input_location, TREE_CODE (t), TREE_TYPE (t), e); return fold_build1_loc (input_location, code, TREE_TYPE (t), e);
} }
case TYPENAME_TYPE: case TYPENAME_TYPE:
...@@ -10672,9 +10670,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10672,9 +10670,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case TYPE_ARGUMENT_PACK: case TYPE_ARGUMENT_PACK:
case NONTYPE_ARGUMENT_PACK: case NONTYPE_ARGUMENT_PACK:
{ {
tree r = TYPE_P (t) tree r = TYPE_P (t) ? cxx_make_type (code) : make_node (code);
? cxx_make_type (TREE_CODE (t))
: make_node (TREE_CODE (t));
tree packed_out = tree packed_out =
tsubst_template_args (ARGUMENT_PACK_ARGS (t), tsubst_template_args (ARGUMENT_PACK_ARGS (t),
args, args,
...@@ -10684,7 +10680,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10684,7 +10680,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* For template nontype argument packs, also substitute into /* For template nontype argument packs, also substitute into
the type. */ the type. */
if (TREE_CODE (t) == NONTYPE_ARGUMENT_PACK) if (code == NONTYPE_ARGUMENT_PACK)
TREE_TYPE (r) = tsubst (TREE_TYPE (t), args, complain, in_decl); TREE_TYPE (r) = tsubst (TREE_TYPE (t), args, complain, in_decl);
return r; return r;
...@@ -10692,8 +10688,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -10692,8 +10688,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
break; break;
default: default:
sorry ("use of %qs in template", sorry ("use of %qs in template", tree_code_name [(int) code]);
tree_code_name [(int) TREE_CODE (t)]);
return error_mark_node; return error_mark_node;
} }
} }
......
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