diff mbox

[C++] PR 69095

Message ID 574320E7.6080909@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 23, 2016, 3:25 p.m. UTC
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.

////////////////////

Comments

Jason Merrill May 23, 2016, 5:30 p.m. UTC | #1
On 05/23/2016 11:25 AM, Paolo Carlini wrote:
> 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...

OK if testing passes.

Jason
diff mbox

Patch

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" }