Commit 264fd142 by Jason Merrill Committed by Jason Merrill

re PR c++/67164 (ICE: tree check: expected class ‘expression’, have…

re PR c++/67164 (ICE: tree check: expected class ‘expression’, have ‘exceptional’ (argument_pack_select) in tree_operand_check, at tree.h:3356)

	PR c++/67164

	* pt.c (copy_template_args): New.
	(tsubst_pack_expansion): Use it.

From-SVN: r233954
parent 6fdb0d67
2016-03-03 Jason Merrill <jason@redhat.com> 2016-03-03 Jason Merrill <jason@redhat.com>
PR c++/67164
* pt.c (copy_template_args): New.
(tsubst_pack_expansion): Use it.
* call.c (build_aggr_conv): Use get_nsdmi. * call.c (build_aggr_conv): Use get_nsdmi.
PR c++/51406 PR c++/51406
......
...@@ -178,6 +178,7 @@ static int check_cv_quals_for_unify (int, tree, tree); ...@@ -178,6 +178,7 @@ static int check_cv_quals_for_unify (int, tree, tree);
static void template_parm_level_and_index (tree, int*, int*); static void template_parm_level_and_index (tree, int*, int*);
static int unify_pack_expansion (tree, tree, tree, static int unify_pack_expansion (tree, tree, tree,
tree, unification_kind_t, bool, bool); tree, unification_kind_t, bool, bool);
static tree copy_template_args (tree);
static tree tsubst_template_arg (tree, tree, tsubst_flags_t, tree); static tree tsubst_template_arg (tree, tree, tsubst_flags_t, tree);
static tree tsubst_template_args (tree, tree, tsubst_flags_t, tree); static tree tsubst_template_args (tree, tree, tsubst_flags_t, tree);
static tree tsubst_template_parms (tree, tree, tsubst_flags_t); static tree tsubst_template_parms (tree, tree, tsubst_flags_t);
...@@ -11037,11 +11038,12 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, ...@@ -11037,11 +11038,12 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
/* For each argument in each argument pack, substitute into the /* For each argument in each argument pack, substitute into the
pattern. */ pattern. */
result = make_tree_vec (len); result = make_tree_vec (len);
tree elem_args = copy_template_args (args);
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
t = gen_elem_of_pack_expansion_instantiation (pattern, packs, t = gen_elem_of_pack_expansion_instantiation (pattern, packs,
i, i,
args, complain, elem_args, complain,
in_decl); in_decl);
TREE_VEC_ELT (result, i) = t; TREE_VEC_ELT (result, i) = t;
if (t == error_mark_node) if (t == error_mark_node)
...@@ -11136,6 +11138,32 @@ make_argument_pack (tree vec) ...@@ -11136,6 +11138,32 @@ make_argument_pack (tree vec)
return pack; return pack;
} }
/* Return an exact copy of template args T that can be modified
independently. */
static tree
copy_template_args (tree t)
{
if (t == error_mark_node)
return t;
int len = TREE_VEC_LENGTH (t);
tree new_vec = make_tree_vec (len);
for (int i = 0; i < len; ++i)
{
tree elt = TREE_VEC_ELT (t, i);
if (elt && TREE_CODE (elt) == TREE_VEC)
elt = copy_template_args (elt);
TREE_VEC_ELT (new_vec, i) = elt;
}
NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_vec)
= NON_DEFAULT_TEMPLATE_ARGS_COUNT (t);
return new_vec;
}
/* Substitute ARGS into the vector or list of template arguments T. */ /* Substitute ARGS into the vector or list of template arguments T. */
static tree static tree
......
// PR c++/67164
// { dg-do compile { target c++11 } }
#include <type_traits>
namespace detail {
template <bool ...b>
struct fast_and
: std::is_same<fast_and<b...>, fast_and<(b, true)...>>
{ };
}
template <typename ...Xn>
struct tuple {
tuple() { }
template <typename ...Yn, typename = typename std::enable_if<
detail::fast_and<std::is_constructible<Xn, Yn&&>::value...>::value
>::type>
tuple(Yn&& ...yn) { }
template <typename ...Yn, typename = typename std::enable_if<
detail::fast_and<std::is_constructible<Xn, Yn const&>::value...>::value
>::type>
tuple(tuple<Yn...> const& other) { }
};
tuple<tuple<>> t{};
tuple<tuple<>> copy = t;
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