Hi,
my fix for c++/15339 caused this regression, where we now reject the
below valid testcase. I think we can handle the problem by adding an
early return to check_redeclaration_no_default_args.
Tested x86_64-linux.
Thanks,
Paolo.
///////////////////////
/cp
2015-03-10 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/65370
* decl.c (check_redeclaration_no_default_args): Avoid spurious
errors for member template functions of specialized class templates.
/testsuite
2015-03-10 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/65370
* g++.dg/other/default11.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 221317)
+++ cp/decl.c (working copy)
@@ -1271,6 +1271,22 @@ check_redeclaration_no_default_args (tree decl)
{
gcc_assert (DECL_DECLARES_FUNCTION_P (decl));
+ /* Don't get fooled by, eg:
+
+ template <typename> class C
+ {
+ template <typename U>
+ C(const C<U>&, bool = false);
+ };
+
+ template <>
+ template <typename U>
+ C<int>::C(const C<U>&, bool); */
+
+ if (DECL_FUNCTION_MEMBER_P (decl)
+ && CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P (DECL_CONTEXT (decl)))
+ return;
+
for (tree t = FUNCTION_FIRST_USER_PARMTYPE (decl);
t && t != void_list_node; t = TREE_CHAIN (t))
if (TREE_PURPOSE (t))
Index: testsuite/g++.dg/other/default11.C
===================================================================
--- testsuite/g++.dg/other/default11.C (revision 0)
+++ testsuite/g++.dg/other/default11.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/65370
+
+template <typename> class C
+{
+ template <typename U>
+ C(const C<U>&, bool = false);
+};
+
+template <>
+template <typename U>
+C<int>::C(const C<U>&, bool);