Commit 8de8fdb4 by Jason Merrill Committed by Jason Merrill

pt.c (find_parameter_packs_r): Handle variable templates.

	* pt.c (find_parameter_packs_r): Handle variable templates.
	(variable_template_specialization_p): New.
	* cp-tree.h: Declare it.

From-SVN: r225692
parent 55b467a0
2015-07-10 Jason Merrill <jason@redhat.com> 2015-07-10 Jason Merrill <jason@redhat.com>
* pt.c (find_parameter_packs_r): Handle variable templates.
(variable_template_specialization_p): New.
* cp-tree.h: Declare it.
* parser.c (cp_parser_template_id): SET_EXPR_LOCATION. * parser.c (cp_parser_template_id): SET_EXPR_LOCATION.
2015-07-10 Eric Botcazou <ebotcazou@adacore.com> 2015-07-10 Eric Botcazou <ebotcazou@adacore.com>
......
...@@ -5771,6 +5771,7 @@ extern bool reregister_specialization (tree, tree, tree); ...@@ -5771,6 +5771,7 @@ extern bool reregister_specialization (tree, tree, tree);
extern tree instantiate_non_dependent_expr (tree); extern tree instantiate_non_dependent_expr (tree);
extern tree instantiate_non_dependent_expr_sfinae (tree, tsubst_flags_t); extern tree instantiate_non_dependent_expr_sfinae (tree, tsubst_flags_t);
extern tree instantiate_non_dependent_expr_internal (tree, tsubst_flags_t); extern tree instantiate_non_dependent_expr_internal (tree, tsubst_flags_t);
extern bool variable_template_specialization_p (tree);
extern bool alias_type_or_template_p (tree); extern bool alias_type_or_template_p (tree);
extern bool alias_template_specialization_p (const_tree); extern bool alias_template_specialization_p (const_tree);
extern bool dependent_alias_template_spec_p (const_tree); extern bool dependent_alias_template_spec_p (const_tree);
......
...@@ -3245,6 +3245,13 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) ...@@ -3245,6 +3245,13 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
ppd, ppd->visited); ppd, ppd->visited);
*walk_subtrees = 0; *walk_subtrees = 0;
} }
else if (variable_template_specialization_p (t))
{
cp_walk_tree (&DECL_TI_ARGS (t),
find_parameter_packs_r,
ppd, ppd->visited);
*walk_subtrees = 0;
}
break; break;
case BASES: case BASES:
...@@ -5351,6 +5358,17 @@ instantiate_non_dependent_expr (tree expr) ...@@ -5351,6 +5358,17 @@ instantiate_non_dependent_expr (tree expr)
return instantiate_non_dependent_expr_sfinae (expr, tf_error); return instantiate_non_dependent_expr_sfinae (expr, tf_error);
} }
/* True iff T is a specialization of a variable template. */
bool
variable_template_specialization_p (tree t)
{
if (!VAR_P (t) || !DECL_LANG_SPECIFIC (t) || !DECL_TEMPLATE_INFO (t))
return false;
tree tmpl = DECL_TI_TEMPLATE (t);
return variable_template_p (tmpl);
}
/* Return TRUE iff T is a type alias, a TEMPLATE_DECL for an alias /* Return TRUE iff T is a type alias, a TEMPLATE_DECL for an alias
template declaration, or a TYPE_DECL for an alias declaration. */ template declaration, or a TYPE_DECL for an alias declaration. */
......
// Test for variable templates in pack expansion
// { dg-do compile { target c++14 } }
template <int I> const int Val = I;
constexpr int f () { return 0; }
template <class T, class ...Ts>
constexpr int f(T t, Ts... ts)
{
return t + f(ts...);
}
template <int... Is>
constexpr int g()
{
return f(Val<Is>...);
}
#define SA(X) static_assert((X),#X)
SA((g<1,2,3,4>() == 1+2+3+4));
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