Commit 4745e4eb by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/33496 (ICE with sizeof for invalid argument pack)

	PR c++/33496
	* pt.c (tsubst_copy) <case SIZEOF_EXPR>: Handle error_mark_node
	returned from tsubst_pack_expansion.
	(tsubst_copy_and_build) <case SIZEOF_EXPR>: Likewise.
	(tsubst_copy_and_build) <case CONSTRUCTOR>: Likewise.

	* g++.dg/cpp0x/variadic76.C: New test.
	* g++.dg/cpp0x/variadic77.C: New test.
	* g++.dg/cpp0x/variadic78.C: New test.

From-SVN: r128630
parent 786025ea
...@@ -9584,6 +9584,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -9584,6 +9584,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* We only want to compute the number of arguments. */ /* We only want to compute the number of arguments. */
tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args, tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
complain, in_decl); complain, in_decl);
if (expanded == error_mark_node)
return error_mark_node;
return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded)); return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
} }
/* Fall through */ /* Fall through */
...@@ -10584,6 +10586,8 @@ tsubst_copy_and_build (tree t, ...@@ -10584,6 +10586,8 @@ tsubst_copy_and_build (tree t,
/* We only want to compute the number of arguments. */ /* We only want to compute the number of arguments. */
tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args, tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
complain, in_decl); complain, in_decl);
if (expanded == error_mark_node)
return error_mark_node;
return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded)); return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
} }
/* Fall through */ /* Fall through */
...@@ -10976,7 +10980,9 @@ tsubst_copy_and_build (tree t, ...@@ -10976,7 +10980,9 @@ tsubst_copy_and_build (tree t,
ce->value = tsubst_pack_expansion (ce->value, args, complain, ce->value = tsubst_pack_expansion (ce->value, args, complain,
in_decl); in_decl);
if (TREE_VEC_LENGTH (ce->value) == 1) if (ce->value == error_mark_node)
;
else if (TREE_VEC_LENGTH (ce->value) == 1)
/* Just move the argument into place. */ /* Just move the argument into place. */
ce->value = TREE_VEC_ELT (ce->value, 0); ce->value = TREE_VEC_ELT (ce->value, 0);
else else
......
2007-09-20 Jakub Jelinek <jakub@redhat.com> 2007-09-20 Jakub Jelinek <jakub@redhat.com>
PR c++/33496
* g++.dg/cpp0x/variadic76.C: New test.
* g++.dg/cpp0x/variadic77.C: New test.
* g++.dg/cpp0x/variadic78.C: New test.
PR c/33238 PR c/33238
PR c/27301 PR c/27301
* gcc.c-torture/execute/20070919-1.c: New test. * gcc.c-torture/execute/20070919-1.c: New test.
// PR c++/33496
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
template<int... N> int foo ()
{
return sizeof... N (); // { dg-error "cannot be used as a function" }
}
int bar ()
{
return foo<0> ();
}
// PR c++/33496
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
template<int M, int N> struct pair
{
int i, j;
pair () : i (M), j (N) {}
};
template<int... M> struct S
{
template<int... N> static int foo ()
{
return sizeof... (pair<M, N>); // { dg-error "mismatched argument pack lengths" }
}
};
int bar ()
{
return S<0, 1, 2>::foo<0, 1> ();
}
// PR c++/33496
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
template<int M, int N> struct pair
{
int i, j;
pair () : i (M), j (N) {}
};
template<int... M> struct S
{
template<int... N> static int *foo ()
{
static int x[] = { (M + N)... }; // { dg-error "mismatched argument pack lengths" }
return x;
}
};
int *bar ()
{
return S<0, 1, 2>::foo<0, 1> ();
}
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