From 3848de0c8101dfb3ea8bbe7e26ea92d9fb2f1fec Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 17 Apr 2012 14:11:34 +0000 Subject: [PATCH] PR c++/38543 * pt.c (determine_specialization): Instead of comparing the number of parms, check that tsubst gives the right answer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186533 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 16 +++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/variadic131.C | 11 +++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic131.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b2fe309e81..83325c1932e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-04-16 Jason Merrill + PR c++/38543 + * pt.c (determine_specialization): Instead of comparing the number + of parms, check that tsubst gives the right answer. + PR c++/50830 * pt.c (convert_template_argument): Handle template template argument packs. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c96b3334fce..383f0d6d557 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1860,6 +1860,7 @@ determine_specialization (tree template_id, { tree decl_arg_types; tree fn_arg_types; + tree insttype; /* In case of explicit specialization, we need to check if the number of template headers appearing in the specialization @@ -1927,7 +1928,8 @@ determine_specialization (tree template_id, template <> void f(); The specialization f is invalid but is not caught by get_bindings below. */ - if (list_length (fn_arg_types) != list_length (decl_arg_types)) + if (cxx_dialect < cxx11 + && list_length (fn_arg_types) != list_length (decl_arg_types)) continue; /* Function templates cannot be specializations; there are @@ -1950,6 +1952,18 @@ determine_specialization (tree template_id, specialize TMPL will produce DECL. */ continue; + if (cxx_dialect >= cxx11) + { + /* Make sure that the deduced arguments actually work. */ + insttype = tsubst (TREE_TYPE (fn), targs, tf_none, NULL_TREE); + if (insttype == error_mark_node) + continue; + fn_arg_types + = skip_artificial_parms_for (fn, TYPE_ARG_TYPES (insttype)); + if (!compparms (fn_arg_types, decl_arg_types)) + continue; + } + /* Save this template, and the arguments deduced. */ templates = tree_cons (targs, fn, templates); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b62f8e5360c..b233a8b8699 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-04-16 Jason Merrill + PR c++/38543 + * g++.dg/cpp0x/variadic131.C: New. + +2012-04-16 Jason Merrill + PR c++/50830 * g++.dg/cpp0x/variadic129.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic131.C b/gcc/testsuite/g++.dg/cpp0x/variadic131.C new file mode 100644 index 00000000000..3006f87ed23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic131.C @@ -0,0 +1,11 @@ +// PR c++/38543 +// { dg-do compile { target c++11 } } + +template< typename ... T > void foo( T ... args ); +template<> void foo( ){} +template<> void foo(int,double){} +int main() +{ + foo( 0, 0.0 ); + return 55; +} -- 2.11.0