diff options
Diffstat (limited to 'gcc-4.9/gcc/cp/pt.c')
-rw-r--r-- | gcc-4.9/gcc/cp/pt.c | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/gcc-4.9/gcc/cp/pt.c b/gcc-4.9/gcc/cp/pt.c index 3951997b0..54676afcc 100644 --- a/gcc-4.9/gcc/cp/pt.c +++ b/gcc-4.9/gcc/cp/pt.c @@ -43,8 +43,10 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "decl.h" #include "toplev.h" +#include "opts.h" #include "timevar.h" #include "tree-iterator.h" +#include "cgraph.h" #include "type-utils.h" #include "gimplify.h" @@ -63,6 +65,13 @@ struct GTY ((chain_next ("%h.next"))) pending_template { static GTY(()) struct pending_template *pending_templates; static GTY(()) struct pending_template *last_pending_template; +void +clear_pending_templates (void) +{ + pending_templates = NULL; + last_pending_template = NULL; +} + int processing_template_parmlist; static int template_header_count; @@ -4423,7 +4432,8 @@ check_default_tmpl_args (tree decl, tree parms, bool is_primary, in the template-parameter-list of the definition of a member of a class template. */ - if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL) + if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL + || (TREE_CODE (decl) == FUNCTION_DECL && DECL_LOCAL_FUNCTION_P (decl))) /* You can't have a function template declaration in a local scope, nor you can you define a member of a class template in a local scope. */ @@ -5345,6 +5355,10 @@ check_valid_ptrmem_cst_expr (tree type, tree expr, return true; if (cxx_dialect >= cxx11 && null_member_pointer_value_p (expr)) return true; + if (processing_template_decl + && TREE_CODE (expr) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (expr, 0)) == OFFSET_REF) + return true; if (complain & tf_error) { error ("%qE is not a valid template argument for type %qT", @@ -14189,11 +14203,7 @@ tsubst_copy_and_build (tree t, if (error_msg) error (error_msg); if (!function_p && identifier_p (decl)) - { - if (complain & tf_error) - unqualified_name_lookup_error (decl); - decl = error_mark_node; - } + decl = unqualified_name_lookup_error (decl); RETURN (decl); } @@ -15636,7 +15646,7 @@ pack_deducible_p (tree parm, tree fn) continue; for (packs = PACK_EXPANSION_PARAMETER_PACKS (type); packs; packs = TREE_CHAIN (packs)) - if (TREE_VALUE (packs) == parm) + if (template_args_equal (TREE_VALUE (packs), parm)) { /* The template parameter pack is used in a function parameter pack. If this is the end of the parameter list, the @@ -16360,8 +16370,9 @@ unify_one_argument (tree tparms, tree targs, tree parm, tree arg, maybe_adjust_types_for_deduction (strict, &parm, &arg, arg_expr); } else - gcc_assert ((TYPE_P (parm) || TREE_CODE (parm) == TEMPLATE_DECL) - == (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL)); + if ((TYPE_P (parm) || TREE_CODE (parm) == TEMPLATE_DECL) + != (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL)) + return unify_template_argument_mismatch (explain_p, parm, arg); /* For deduction from an init-list we need the actual list. */ if (arg_expr && BRACE_ENCLOSED_INITIALIZER_P (arg_expr)) @@ -16697,7 +16708,16 @@ resolve_overloaded_unification (tree tparms, int i = TREE_VEC_LENGTH (targs); for (; i--; ) if (TREE_VEC_ELT (tempargs, i)) - TREE_VEC_ELT (targs, i) = TREE_VEC_ELT (tempargs, i); + { + tree old = TREE_VEC_ELT (targs, i); + tree new_ = TREE_VEC_ELT (tempargs, i); + if (new_ && old && ARGUMENT_PACK_P (old) + && ARGUMENT_PACK_EXPLICIT_ARGS (old)) + /* Don't forget explicit template arguments in a pack. */ + ARGUMENT_PACK_EXPLICIT_ARGS (new_) + = ARGUMENT_PACK_EXPLICIT_ARGS (old); + TREE_VEC_ELT (targs, i) = new_; + } } if (good) return true; @@ -19766,7 +19786,13 @@ instantiate_decl (tree d, int defer_ok, when marked as "extern template". */ if (!(external_p && VAR_P (d))) add_pending_template (d); - goto out; + { + if (L_IPO_COMP_MODE) + /* Capture module info. */ + if (TREE_CODE (d) == VAR_DECL) + varpool_node_for_decl (d); + goto out; + } } /* Tell the repository that D is available in this translation unit -- and see if it is supposed to be instantiated here. */ @@ -20936,7 +20962,12 @@ type_dependent_expression_p (tree expression) return true; if (BASELINK_P (expression)) - expression = BASELINK_FUNCTIONS (expression); + { + if (BASELINK_OPTYPE (expression) + && dependent_type_p (BASELINK_OPTYPE (expression))) + return true; + expression = BASELINK_FUNCTIONS (expression); + } if (TREE_CODE (expression) == TEMPLATE_ID_EXPR) { |