Hi,
finally sending a patch for this issue. As noticed by submitter himself,
it appears to boil down to a rather straightforward case of not
rejecting unexpanded parameter packs in default arguments. In order to
handle all the combinations (in/out of class, template
parameter/function parameter) I added calls of
check_for_bare_parameter_packs both to cp_parser_default_argument and
cp_parser_late_parsing_default_args (to have a meaningful location for
the latter, the patchlet which I sent earlier today is a must). Tested
x86_64-linux.
Thanks,
Paolo.
//////////////////////
/cp
2016-05-22 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/69095
* parser.c (cp_parser_default_argument): Call
check_for_bare_parameter_packs.
(cp_parser_late_parsing_default_args): Likewise.
/testsuite
2016-05-22 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/69095
* g++.dg/cpp0x/variadic168.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 236569)
+++ cp/parser.c (working copy)
@@ -20673,6 +20673,8 @@ cp_parser_default_argument (cp_parser *parser, boo
}
if (BRACE_ENCLOSED_INITIALIZER_P (default_argument))
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
+ if (check_for_bare_parameter_packs (default_argument))
+ default_argument = error_mark_node;
if (template_parm_p)
pop_deferring_access_checks ();
parser->greater_than_is_operator_p = saved_greater_than_is_operator_p;
@@ -26403,6 +26405,9 @@ cp_parser_late_parsing_default_args (cp_parser *pa
continue;
}
+ if (check_for_bare_parameter_packs (parsed_arg))
+ parsed_arg = error_mark_node;
+
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
Index: testsuite/g++.dg/cpp0x/variadic168.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic168.C (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic168.C (working copy)
@@ -0,0 +1,18 @@
+// PR c++/69095
+// { dg-do compile { target c++11 } }
+
+struct B1 {
+ template <typename Ret, typename... Args, unsigned = sizeof(Args)> // {
dg-error "parameter packs not expanded" }
+ void insert(Ret);
+};
+
+struct B2 {
+ template <typename Ret, typename... Args>
+ void insert(Ret, unsigned = sizeof(Args)); // { dg-error "parameter packs
not expanded" }
+};
+
+template <typename Ret, typename... Args, unsigned = sizeof(Args)> // {
dg-error "parameter packs not expanded" }
+void insert1(Ret);
+
+template <typename Ret, typename... Args>
+void insert2(Ret, unsigned = sizeof(Args)); // { dg-error "parameter packs not
expanded" }