aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/cp/pt.c
diff options
context:
space:
mode:
authorJing Yu <jingyu@google.com>2011-01-30 22:18:29 -0800
committerJing Yu <jingyu@google.com>2011-01-30 22:18:29 -0800
commit4a66e756636cb8364582ea503abd10d76f5b4aa3 (patch)
tree9660204ec085888a0601a6460c967b204a63d5f3 /gcc-4.4.3/gcc/cp/pt.c
parentb6be42e837844cce5283f42fcfac31e6d66a277d (diff)
downloadtoolchain_gcc-4a66e756636cb8364582ea503abd10d76f5b4aa3.tar.gz
toolchain_gcc-4a66e756636cb8364582ea503abd10d76f5b4aa3.tar.bz2
toolchain_gcc-4a66e756636cb8364582ea503abd10d76f5b4aa3.zip
Upgrade gcc-4.4.3 for Android toolchain.
- Backport upstream patches to support arm hardfp. - Backport gcc-4.5 patches to support -march=atom. Now it is able to build atom toolchain with glibc from this branch - Develop a bunch of optimizations - Fix a few arm dejagnu failures To-do list: - Support Android/atom - Fix ia32 bootstrap failure Change-Id: I5e10dcd21620d4d8ca984d1d1707a76067e61691
Diffstat (limited to 'gcc-4.4.3/gcc/cp/pt.c')
-rw-r--r--gcc-4.4.3/gcc/cp/pt.c100
1 files changed, 90 insertions, 10 deletions
diff --git a/gcc-4.4.3/gcc/cp/pt.c b/gcc-4.4.3/gcc/cp/pt.c
index 663d42037..57e5884ed 100644
--- a/gcc-4.4.3/gcc/cp/pt.c
+++ b/gcc-4.4.3/gcc/cp/pt.c
@@ -87,6 +87,12 @@ struct pending_attribute GTY (()) {
static GTY(()) struct pending_attribute *pending_lock_attributes = NULL;
+typedef struct pending_attribute *pending_attribute_p;
+DEF_VEC_P(pending_attribute_p);
+DEF_VEC_ALLOC_P(pending_attribute_p,gc);
+
+static GTY(()) VEC(pending_attribute_p,gc) *pending_lock_attr_stack;
+
int processing_template_parmlist;
static int template_header_count;
@@ -2809,6 +2815,7 @@ expand_template_argument_pack (tree args)
tree result_args = NULL_TREE;
int in_arg, out_arg = 0, nargs = args ? TREE_VEC_LENGTH (args) : 0;
int num_result_args = -1;
+ int non_default_args_count = -1;
/* First, determine if we need to expand anything, and the number of
slots we'll need. */
@@ -2838,6 +2845,9 @@ expand_template_argument_pack (tree args)
/* Expand arguments. */
result_args = make_tree_vec (num_result_args);
+ if (NON_DEFAULT_TEMPLATE_ARGS_COUNT (args))
+ non_default_args_count =
+ GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (args);
for (in_arg = 0; in_arg < nargs; ++in_arg)
{
tree arg = TREE_VEC_ELT (args, in_arg);
@@ -2847,6 +2857,8 @@ expand_template_argument_pack (tree args)
int i, num_packed = TREE_VEC_LENGTH (packed);
for (i = 0; i < num_packed; ++i, ++out_arg)
TREE_VEC_ELT (result_args, out_arg) = TREE_VEC_ELT(packed, i);
+ if (non_default_args_count > 0)
+ non_default_args_count += num_packed;
}
else
{
@@ -2854,7 +2866,8 @@ expand_template_argument_pack (tree args)
++out_arg;
}
}
-
+ if (non_default_args_count >= 0)
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (result_args, non_default_args_count);
return result_args;
}
@@ -3213,6 +3226,10 @@ current_template_args (void)
/* Turn this argument into a TYPE_ARGUMENT_PACK
with a single element, which expands T. */
tree vec = make_tree_vec (1);
+#ifdef ENABLE_CHECKING
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
+ (vec, TREE_VEC_LENGTH (vec));
+#endif
TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
t = make_node (TYPE_ARGUMENT_PACK);
@@ -3229,6 +3246,10 @@ current_template_args (void)
with a single element, which expands T. */
tree vec = make_tree_vec (1);
tree type = TREE_TYPE (TEMPLATE_PARM_DECL (t));
+#ifdef ENABLE_CHECKING
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
+ (vec, TREE_VEC_LENGTH (vec));
+#endif
TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
t = make_node (NONTYPE_ARGUMENT_PACK);
@@ -3241,6 +3262,10 @@ current_template_args (void)
}
}
+#ifdef ENABLE_CHECKING
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (a, TREE_VEC_LENGTH (a));
+#endif
+
if (length > 1)
TREE_VEC_ELT (args, --l) = a;
else
@@ -5300,6 +5325,10 @@ coerce_template_parameter_pack (tree parms,
}
SET_ARGUMENT_PACK_ARGS (argument_pack, packed_args);
+#ifdef ENABLE_CHECKING
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,
+ TREE_VEC_LENGTH (packed_args));
+#endif
return argument_pack;
}
@@ -5452,9 +5481,16 @@ coerce_template_parms (tree parms,
}
}
else if (require_all_args)
- /* There must be a default arg in this case. */
- arg = tsubst_template_arg (TREE_PURPOSE (parm), new_args,
- complain, in_decl);
+ {
+ /* There must be a default arg in this case. */
+ arg = tsubst_template_arg (TREE_PURPOSE (parm), new_args,
+ complain, in_decl);
+ /* The position of the first default template argument,
+ is also the number of non-defaulted arguments in NEW_INNER_ARGS.
+ Record that. */
+ if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args, arg_idx);
+ }
else
break;
@@ -5484,6 +5520,12 @@ coerce_template_parms (tree parms,
if (lost)
return error_mark_node;
+#ifdef ENABLE_CHECKING
+ if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args,
+ TREE_VEC_LENGTH (new_inner_args));
+#endif
+
return new_inner_args;
}
@@ -7102,12 +7144,18 @@ instantiate_class_template (tree type)
push_to_top_level ();
+ /* Push the existing pending lock attributes to the stack. */
+ VEC_safe_push (pending_attribute_p, gc, pending_lock_attr_stack,
+ pending_lock_attributes);
+ pending_lock_attributes = NULL;
+
SET_CLASSTYPE_INTERFACE_UNKNOWN (type);
- /* Set the input location to the template definition. This is needed
- if tsubsting causes an error. */
- typedecl = TYPE_MAIN_DECL (type);
- input_location = DECL_SOURCE_LOCATION (typedecl);
+ /* Set the input location to the most specialized template definition.
+ This is needed if tsubsting causes an error. */
+ typedecl = TYPE_MAIN_DECL (pattern);
+ input_location = DECL_SOURCE_LOCATION (TYPE_NAME (type)) =
+ DECL_SOURCE_LOCATION (typedecl);
TYPE_HAS_USER_CONSTRUCTOR (type) = TYPE_HAS_USER_CONSTRUCTOR (pattern);
TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
@@ -7528,10 +7576,13 @@ instantiate_class_template (tree type)
cplus_decl_attributes (&pa->decl, t, pa->attr_flags);
}
parsing_lock_attribute = false;
- pending_lock_attributes = NULL;
input_location = saved_location;
}
+ /* Pop out the pending attributes of the outer class/template. */
+ pending_lock_attributes = VEC_pop (pending_attribute_p,
+ pending_lock_attr_stack);
+
pop_nested_class ();
pop_from_top_level ();
pop_deferring_access_checks ();
@@ -7964,6 +8015,19 @@ tsubst_template_args (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* Make space for the expanded arguments coming from template
argument packs. */
t = make_tree_vec (len + expanded_len_adjust);
+ /* ORIG_T can contain TREE_VECs. That happens if ORIG_T contains the
+ arguments for a member template.
+ In that case each TREE_VEC in ORIG_T represents a level of template
+ arguments, and ORIG_T won't carry any non defaulted argument count.
+ It will rather be the nested TREE_VECs that will carry one.
+ In other words, ORIG_T carries a non defaulted argument count only
+ if it doesn't contain any nested TREE_VEC. */
+ if (NON_DEFAULT_TEMPLATE_ARGS_COUNT (orig_t))
+ {
+ int count = GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (orig_t);
+ count += expanded_len_adjust;
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (t, count);
+ }
for (i = 0, out = 0; i < len; i++)
{
if ((PACK_EXPANSION_P (TREE_VEC_ELT (orig_t, i))
@@ -9821,7 +9885,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
But, such constructs have already been resolved by this
point, so here CTX really should have complete type, unless
it's a partial instantiation. */
- ctx = complete_type (ctx);
+ if (!(complain & tf_no_class_instantiations))
+ ctx = complete_type (ctx);
if (!COMPLETE_TYPE_P (ctx))
{
if (complain & tf_error)
@@ -12604,6 +12669,10 @@ type_unification_real (tree tparms,
gcc_assert (!xargs || TREE_CODE (xargs) == TREE_LIST);
gcc_assert (ntparms > 0);
+ /* Reset the number of non-defaulted template arguments contained
+ in in TARGS. */
+ NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs) = NULL_TREE;
+
switch (strict)
{
case DEDUCE_CALL:
@@ -12789,6 +12858,11 @@ type_unification_real (tree tparms,
else
{
TREE_VEC_ELT (targs, i) = arg;
+ /* The position of the first default template argument,
+ is also the number of non-defaulted arguments in TARGS.
+ Record that. */
+ if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, i);
continue;
}
}
@@ -12816,6 +12890,10 @@ type_unification_real (tree tparms,
return 2;
}
+#ifdef ENABLE_CHECKING
+ if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
+ SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, TREE_VEC_LENGTH (targs));
+#endif
return 0;
}
@@ -15575,6 +15653,8 @@ instantiate_decl (tree d, int defer_ok,
&& !DECL_NOT_REALLY_EXTERN (d))
mark_definable (d);
+ DECL_SOURCE_LOCATION (td) = DECL_SOURCE_LOCATION (code_pattern);
+ DECL_SOURCE_LOCATION (d) = DECL_SOURCE_LOCATION (code_pattern);
input_location = DECL_SOURCE_LOCATION (d);
/* If D is a member of an explicitly instantiated class template,