From 2f93f02ca356a40d90f3df0eac1adf1239572d27 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 4 Dec 2007 20:49:08 +0000 Subject: [PATCH] re PR c++/33509 (tsubst_pack_expansion assumed to return TREE_VEC) 2007-12-04 Douglas Gregor 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 PR c++/33509 * g++.dg/cpp0x/variadic-throw.C: New. From-SVN: r130605 --- gcc/cp/ChangeLog | 7 ++++++ gcc/cp/pt.c | 19 +++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/variadic-throw.C | 25 +++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-throw.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b99ba8cd984..f694c8866ef6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2007-12-04 Douglas Gregor + + 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 PR c++/33091 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f7d694613c78..b64ccf83c563 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 38c24c0c4ce9..13e2cbaca09a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-12-04 Douglas Gregor + + PR c++/33509 + * g++.dg/cpp0x/variadic-throw.C: New. + 2007-12-04 Douglas Gregor PR c++/33091 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C b/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C new file mode 100644 index 000000000000..f2ff652d8a0f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C @@ -0,0 +1,25 @@ +// { dg-options -std=c++0x } +// PR c++/33509 +template struct pair +{ + int i, j; + pair() : i(M), j(N) {} +}; + +template struct S +{ + template static int foo() throw (pair ...) // { 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> (); +} -- 2.47.2