diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 93cd960a61139535f0cbc6fc1978056c289eec6a..c08314449bf6088cd3b25fe3aac25f098377de1d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2011-11-20 Jason Merrill <jason@redhat.com> + * pt.c (tsubst_pack_expansion): Fix SFINAE. + PR c++/48322 * cp-tree.h (PACK_EXPANSION_EXTRA_ARGS): New. * cp-tree.def (EXPR_PACK_EXPANSION): Add an operand for it. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f0ee0c5f17e5da7bfedacbcfc17fda180e554b92..2ba26b206bdc4a153b9c8851364c48e6109a7812 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9350,7 +9350,9 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, len = my_len; else if (len != my_len) { - if (TREE_CODE (t) == TYPE_PACK_EXPANSION) + if (!(complain & tf_error)) + /* Fail quietly. */; + else if (TREE_CODE (t) == TYPE_PACK_EXPANSION) error ("mismatched argument pack lengths while expanding " "%<%T%>", pattern); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae30.C b/gcc/testsuite/g++.dg/cpp0x/sfinae30.C new file mode 100644 index 0000000000000000000000000000000000000000..6fcf5f756090ea5193d8a33e9b6a62b2b767b9d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae30.C @@ -0,0 +1,25 @@ +// { dg-do compile { target c++11 } } + +template <class... T> struct tuple; +template <class T> struct tuple<T> { T t; }; + +template <class T, class U> struct pair; +template<> struct pair<int,double> { }; + +template <class... Ts> +struct A +{ + template <class... Us, + class V = tuple<pair<Ts,Us>...> > + static void f(Us...) + { + V v; + } + template <class U> + static void f(bool); +}; + +int main() +{ + A<int,float>::f<double>(1.0); +}