diff mbox series

C++ PATCH for c++/86728, stdarg generic lambda

Message ID CADzB+2nfkaHEjKCZ3g8iftPPEYx0b65TNh8i+MsYiCSF7x3LMg@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/86728, stdarg generic lambda | expand

Commit Message

Jason Merrill Aug. 11, 2018, 10:46 a.m. UTC
My patch for 64095 regressed this testcase because the moved code
wasn't checking for a declarator-id before turning the implicit
template parameter into a pack.

Tested x86_64-pc-linux-gnu, applying to trunk, 8, and 7.
diff mbox series

Patch

commit ba6b0740aa4f5e649ccf5d75381ae378e07567c0
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Aug 10 23:38:29 2018 +1200

            PR c++/86728 - C variadic generic lambda.
    
            * parser.c (cp_parser_parameter_declaration): Don't turn 'auto' into
            a pack if it's followed by a declarator-id.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 93c812f80d7..8cfcd150705 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -21722,7 +21722,8 @@  cp_parser_parameter_declaration (cp_parser *parser,
      parameter was introduced during cp_parser_parameter_declaration,
      change any implicit parameters introduced into packs.  */
   if (parser->implicit_template_parms
-      && (token->type == CPP_ELLIPSIS
+      && ((token->type == CPP_ELLIPSIS
+	   && declarator_can_be_parameter_pack (declarator))
 	  || (declarator && declarator->parameter_pack_p)))
     {
       int latest_template_parm_idx = TREE_VEC_LENGTH
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic19.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic19.C
new file mode 100644
index 00000000000..e78677de0b5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic19.C
@@ -0,0 +1,4 @@ 
+// PR c++/86728
+// { dg-do compile { target c++14 } }
+
+auto c = [](auto x ...) { };