aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/cp/pt.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8/gcc/cp/pt.c')
-rw-r--r--gcc-4.8/gcc/cp/pt.c88
1 files changed, 71 insertions, 17 deletions
diff --git a/gcc-4.8/gcc/cp/pt.c b/gcc-4.8/gcc/cp/pt.c
index 5885021a4..c44e3d0b2 100644
--- a/gcc-4.8/gcc/cp/pt.c
+++ b/gcc-4.8/gcc/cp/pt.c
@@ -1419,6 +1419,8 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend,
= DECL_DECLARED_INLINE_P (fn);
DECL_SOURCE_LOCATION (clone)
= DECL_SOURCE_LOCATION (fn);
+ DECL_DELETED_FN (clone)
+ = DECL_DELETED_FN (fn);
}
check_specialization_namespace (tmpl);
@@ -3436,7 +3438,7 @@ expand_template_argument_pack (tree args)
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;
+ non_default_args_count += num_packed - 1;
}
else
{
@@ -3491,6 +3493,11 @@ check_template_shadow (tree decl)
|| TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
return true;
+ /* Don't complain about the injected class name, as we've already
+ complained about the class itself. */
+ if (DECL_SELF_REFERENCE_P (decl))
+ return false;
+
error ("declaration of %q+#D", decl);
error (" shadows template parm %q+#D", olddecl);
return false;
@@ -6672,6 +6679,8 @@ coerce_template_parms (tree parms,
/* Store this argument. */
if (arg == error_mark_node)
lost++;
+ if (lost)
+ break;
TREE_VEC_ELT (new_inner_args, parm_idx) = arg;
/* We are done with all of the arguments. */
@@ -12694,27 +12703,43 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
tsubst_expr ((NODE), args, complain, in_decl, \
integral_constant_expression_p)
tree decl, init, cond, incr;
- bool init_decl;
init = TREE_VEC_ELT (OMP_FOR_INIT (t), i);
gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
decl = TREE_OPERAND (init, 0);
init = TREE_OPERAND (init, 1);
- /* Do this before substituting into decl to handle 'auto'. */
- init_decl = (init && TREE_CODE (init) == DECL_EXPR);
- init = RECUR (init);
- decl = RECUR (decl);
- if (init_decl)
+ tree decl_expr = NULL_TREE;
+ if (init && TREE_CODE (init) == DECL_EXPR)
{
- gcc_assert (!processing_template_decl);
- init = DECL_INITIAL (decl);
- DECL_INITIAL (decl) = NULL_TREE;
+ /* We need to jump through some hoops to handle declarations in the
+ for-init-statement, since we might need to handle auto deduction,
+ but we need to keep control of initialization. */
+ decl_expr = init;
+ init = DECL_INITIAL (DECL_EXPR_DECL (init));
+ decl = tsubst_decl (decl, args, complain);
}
+ else
+ decl = RECUR (decl);
+ init = RECUR (init);
+
+ tree auto_node = type_uses_auto (TREE_TYPE (decl));
+ if (auto_node && init)
+ TREE_TYPE (decl)
+ = do_auto_deduction (TREE_TYPE (decl), init, auto_node);
gcc_assert (!type_dependent_expression_p (decl));
if (!CLASS_TYPE_P (TREE_TYPE (decl)))
{
+ if (decl_expr)
+ {
+ /* Declare the variable, but don't let that initialize it. */
+ tree init_sav = DECL_INITIAL (DECL_EXPR_DECL (decl_expr));
+ DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = NULL_TREE;
+ RECUR (decl_expr);
+ DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = init_sav;
+ }
+
cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i));
incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i);
if (TREE_CODE (incr) == MODIFY_EXPR)
@@ -12731,7 +12756,13 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
return;
}
- if (init && !init_decl)
+ if (decl_expr)
+ {
+ /* Declare and initialize the variable. */
+ RECUR (decl_expr);
+ init = NULL_TREE;
+ }
+ else if (init)
{
tree c;
for (c = *clauses; c ; c = OMP_CLAUSE_CHAIN (c))
@@ -13710,6 +13741,10 @@ tsubst_copy_and_build (tree t,
RETURN (r);
}
+ case POINTER_PLUS_EXPR:
+ return fold_build_pointer_plus (RECUR (TREE_OPERAND (t, 0)),
+ RECUR (TREE_OPERAND (t, 1)));
+
case SCOPE_REF:
RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,
/*address_p=*/false));
@@ -14471,12 +14506,12 @@ tsubst_copy_and_build (tree t,
case TRAIT_EXPR:
{
- tree type1 = tsubst_copy (TRAIT_EXPR_TYPE1 (t), args,
+ tree type1 = tsubst (TRAIT_EXPR_TYPE1 (t), args,
complain, in_decl);
tree type2 = TRAIT_EXPR_TYPE2 (t);
if (type2)
- type2 = tsubst_copy (type2, args, complain, in_decl);
+ type2 = tsubst (type2, args, complain, in_decl);
RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2));
}
@@ -14778,6 +14813,8 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
/* Instantiation of the function happens in the context of the function
template, not the context of the overload resolution we're doing. */
push_to_top_level ();
+ struct pointer_map_t *saved_local_specializations = local_specializations;
+ local_specializations = NULL;
/* If there are dependent arguments, e.g. because we're doing partial
ordering, make sure processing_template_decl stays set. */
if (uses_template_parms (targ_ptr))
@@ -14793,6 +14830,7 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
targ_ptr, complain, gen_tmpl);
if (DECL_CLASS_SCOPE_P (gen_tmpl))
pop_nested_class ();
+ local_specializations = saved_local_specializations;
pop_from_top_level ();
if (fndecl == error_mark_node)
@@ -15192,8 +15230,11 @@ fn_type_unification (tree fn,
/* If we're looking for an exact match, check that what we got
is indeed an exact match. It might not be if some template
- parameters are used in non-deduced contexts. */
- if (strict == DEDUCE_EXACT)
+ parameters are used in non-deduced contexts. But don't check
+ for an exact match if we have dependent template arguments;
+ in that case we're doing partial ordering, and we already know
+ that we have two candidates that will provide the actual type. */
+ if (strict == DEDUCE_EXACT && !any_dependent_template_arguments_p (targs))
{
tree substed = TREE_TYPE (decl);
unsigned int i;
@@ -15749,7 +15790,7 @@ resolve_overloaded_unification (tree tparms,
if (subargs != error_mark_node
&& !any_dependent_template_arguments_p (subargs))
{
- elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE);
+ elem = TREE_TYPE (instantiate_template (fn, subargs, tf_none));
if (try_one_overload (tparms, targs, tempargs, parm,
elem, strict, sub_strict, addr_p, explain_p)
&& (!goodfn || !same_type_p (goodfn, elem)))
@@ -16207,6 +16248,9 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
tree pattern = PACK_EXPANSION_PATTERN (parm);
tree pack, packs = NULL_TREE;
int i, start = TREE_VEC_LENGTH (packed_parms) - 1;
+
+ packed_args = expand_template_argument_pack (packed_args);
+
int len = TREE_VEC_LENGTH (packed_args);
/* Determine the parameter packs we will be deducing from the
@@ -16574,9 +16618,11 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
if (TREE_CODE (arg) != BOUND_TEMPLATE_TEMPLATE_PARM
&& !CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P (arg))
return unify_template_deduction_failure (explain_p, parm, arg);
-
{
tree parmvec = TYPE_TI_ARGS (parm);
+ /* An alias template name is never deduced. */
+ if (TYPE_ALIAS_P (arg))
+ arg = strip_typedefs (arg);
tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg));
tree full_argvec = add_to_template_args (targs, argvec);
tree parm_parms
@@ -18552,6 +18598,10 @@ maybe_instantiate_noexcept (tree fn)
{
tree fntype, spec, noex, clone;
+ /* Don't instantiate a noexcept-specification from template context. */
+ if (processing_template_decl)
+ return;
+
if (DECL_CLONED_FUNCTION_P (fn))
fn = DECL_CLONED_FUNCTION (fn);
fntype = TREE_TYPE (fn);
@@ -19954,6 +20004,10 @@ type_dependent_expression_p (tree expression)
if (TREE_CODE (expression) == SCOPE_REF)
return false;
+ /* Always dependent, on the number of arguments if nothing else. */
+ if (TREE_CODE (expression) == EXPR_PACK_EXPANSION)
+ return true;
+
if (BASELINK_P (expression))
expression = BASELINK_FUNCTIONS (expression);