[C++ Patch] PR 69095

Paolo Carlini paolo.carlini@oracle.com
Mon May 23 15:25:00 GMT 2016


Hi,

On 23/05/2016 15:32, Jason Merrill wrote:
> On 05/22/2016 02:26 PM, Paolo Carlini wrote:
>> 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
>
> Hmm, would it make sense to check in cp_parser_initializer?
Oh yes. The below is already past g++.dg/tm...

Thanks!
Paolo.

////////////////////
-------------- next part --------------
Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 236592)
+++ cp/parser.c	(working copy)
@@ -20800,6 +20800,9 @@ cp_parser_initializer (cp_parser* parser, bool* is
       init = error_mark_node;
     }
 
+  if (check_for_bare_parameter_packs (init))
+    init = error_mark_node;
+
   return init;
 }
 
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" }


More information about the Gcc-patches mailing list