aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-09-20 23:21:03 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2007-09-20 23:21:03 +0200
commit4745e4eb75aed535cc05f3393dd1209ffd8bac09 (patch)
tree152c32920a9618a6fbfd58200e59acead5c6f3c4 /gcc
parent786025ea79bffb3746e1964e561dae17f37dc8af (diff)
downloadgcc-4745e4eb75aed535cc05f3393dd1209ffd8bac09.zip
gcc-4745e4eb75aed535cc05f3393dd1209ffd8bac09.tar.gz
gcc-4745e4eb75aed535cc05f3393dd1209ffd8bac09.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic76.C13
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic77.C22
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic78.C23
5 files changed, 70 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 17acbaf..8accea4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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. */
tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
complain, in_decl);
+ if (expanded == error_mark_node)
+ return error_mark_node;
return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
}
/* Fall through */
@@ -10584,6 +10586,8 @@ tsubst_copy_and_build (tree t,
/* We only want to compute the number of arguments. */
tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
complain, in_decl);
+ if (expanded == error_mark_node)
+ return error_mark_node;
return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
}
/* Fall through */
@@ -10976,7 +10980,9 @@ tsubst_copy_and_build (tree t,
ce->value = tsubst_pack_expansion (ce->value, args, complain,
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. */
ce->value = TREE_VEC_ELT (ce->value, 0);
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 675351d..f1186e8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
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/27301
* gcc.c-torture/execute/20070919-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic76.C b/gcc/testsuite/g++.dg/cpp0x/variadic76.C
new file mode 100644
index 0000000..a9f8eab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic76.C
@@ -0,0 +1,13 @@
+// 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> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic77.C b/gcc/testsuite/g++.dg/cpp0x/variadic77.C
new file mode 100644
index 0000000..43f2d1e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic77.C
@@ -0,0 +1,22 @@
+// 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> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic78.C b/gcc/testsuite/g++.dg/cpp0x/variadic78.C
new file mode 100644
index 0000000..9e2b84a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic78.C
@@ -0,0 +1,23 @@
+// 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> ();
+}