This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 18 Nov 2007 09:38:27 -0500
- Subject: [C++ PATCH] Handle TYPE_PACK_EXPANSION return in tsubst_exception_specification
This little patch fixes PR 33509, a P2 ice-on-valid where we failed to
handle the instantiation of exception specifications that involve
parameter packs from multiple levels of template parameters. The fix
is relatively simple; we just deal with the resulting
TYPE_PACK_EXPANSION explicitly.
Tested i686-pc-linux-gnu; okay for mainline?
- Doug
2007-11-18 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-11-18 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33509
* g++.dg/cpp0x/variadic-throw.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 130268)
+++ cp/pt.c (working copy)
@@ -8653,7 +8653,24 @@ tsubst_exception_specification (tree fnt
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: testsuite/g++.dg/cpp0x/variadic-throw.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic-throw.C (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic-throw.C (revision 0)
@@ -0,0 +1,20 @@
+// { 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>...)
+ {
+ return 1;
+ }
+};
+
+int bar ()
+{
+ return S<0, 1, 2>::foo<0, 1, 3> ();
+}