OSDN Git Service

PR c++/33496
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Sep 2007 21:21:03 +0000 (21:21 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Sep 2007 21:21:03 +0000 (21:21 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128630 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic76.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/variadic77.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/variadic78.C [new file with mode: 0644]

index 17acbaf..8accea4 100644 (file)
@@ -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
index 675351d..f1186e8 100644 (file)
@@ -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 (file)
index 0000000..a9f8eab
--- /dev/null
@@ -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 (file)
index 0000000..43f2d1e
--- /dev/null
@@ -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 (file)
index 0000000..9e2b84a
--- /dev/null
@@ -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> ();
+}