2007-12-04 Douglas Gregor <doug.gregor@gmail.com>
authordgregor <dgregor@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Dec 2007 20:49:08 +0000 (20:49 +0000)
committerdgregor <dgregor@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Dec 2007 20:49:08 +0000 (20:49 +0000)
       PR c++/33509
       * pt.c (tsubst_exception_specification): Handle substitutions into
       member templates, where tsubst_pack_expansion returns a
       TYPE_PACK_EXPANSION.

2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>

       PR c++/33509
       * g++.dg/cpp0x/variadic-throw.C: New.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic-throw.C [new file with mode: 0644]

index 9b99ba8..f694c88 100644 (file)
@@ -1,5 +1,12 @@
 2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>
 
+       PR c++/33509
+       * pt.c (tsubst_exception_specification): Handle substitutions into
+       member templates, where tsubst_pack_expansion returns a
+       TYPE_PACK_EXPANSION.
+
+2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>
+
        PR c++/33091
        * pt.c (unify_pack_expansion): If we didn't deduce any actual
        bindings for the template parameter pack, don't try to keep the
index f7d6946..b64ccf8 100644 (file)
@@ -8653,7 +8653,24 @@ tsubst_exception_specification (tree fntype,
                 expanded_specs = tsubst_pack_expansion (TREE_VALUE (specs),
                                                        args, complain,
                                                        in_decl);
-                len = TREE_VEC_LENGTH (expanded_specs);
+
+               if (expanded_specs == error_mark_node)
+                 return error_mark_node;
+               else if (TREE_CODE (expanded_specs) == TREE_VEC)
+                 len = TREE_VEC_LENGTH (expanded_specs);
+               else
+                 {
+                   /* We're substituting into a member template, so
+                      we got a TYPE_PACK_EXPANSION back.  Add that
+                      expansion and move on.  */
+                   gcc_assert (TREE_CODE (expanded_specs) 
+                               == TYPE_PACK_EXPANSION);
+                   new_specs = add_exception_specifier (new_specs,
+                                                        expanded_specs,
+                                                        complain);
+                   specs = TREE_CHAIN (specs);
+                   continue;
+                 }
               }
 
             for (i = 0; i < len; ++i)
index 38c24c0..13e2cba 100644 (file)
@@ -1,5 +1,10 @@
 2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>
 
+       PR c++/33509
+       * g++.dg/cpp0x/variadic-throw.C: New.
+
+2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>
+
        PR c++/33091
        * g++.dg/cpp0x/variadic-unify.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C b/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C
new file mode 100644 (file)
index 0000000..f2ff652
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-options -std=c++0x }
+// PR c++/33509
+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() throw (pair <M, N>...) // { dg-error "mismatched|no matching" }
+  {
+    return 1;
+  }
+};
+
+int bar ()
+{
+  return S<0, 1, 2>::foo<0, 1, 3> ();
+}
+
+int wibble()
+{
+  return S<0, 1, 2>::foo<0, 1> ();
+}