]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/59636 ([c++1y] ICE with missing template parameter in lambda)
authorAdam Butcher <adam@jessamine.co.uk>
Mon, 6 Jan 2014 18:22:29 +0000 (18:22 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Mon, 6 Jan 2014 18:22:29 +0000 (18:22 +0000)
Fix PR c++/59636

PR c++/59636
* cp/parser.c (cp_parser_template_parameter): Early out with
error_mark_node if parameter declaration was not parsed.

* g++.dg/cpp1y/pr59636.C: New testcase.

From-SVN: r206369

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr59636.C [new file with mode: 0644]

index 3bc68fc95df5ab32458382637deaa9cfe01e368d..33228977ca5db7f4433bf05044b87a0e02960ce0 100644 (file)
@@ -4,6 +4,10 @@
        * cp/lambda.c (maybe_add_lambda_conv_op): Handle marking conversion
        function as unimplemented for generic lambdas with varargs.
 
+       PR c++/59636
+       * cp/parser.c (cp_parser_template_parameter): Early out with
+       error_mark_node if parameter declaration was not parsed.
+
 2014-01-03  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/58950
index c99c1fcb64547e98dbb51df0571169e6b7e1f8a8..4d970260a1b31201ab4eeab6264bde2b3ac289ec 100644 (file)
@@ -12977,20 +12977,21 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type,
      = cp_parser_parameter_declaration (parser, /*template_parm_p=*/true,
                                        /*parenthesized_p=*/NULL);
 
+  if (!parameter_declarator)
+    return error_mark_node;
+
   /* If the parameter declaration is marked as a parameter pack, set
      *IS_PARAMETER_PACK to notify the caller. Also, unmark the
      declarator's PACK_EXPANSION_P, otherwise we'll get errors from
      grokdeclarator. */
-  if (parameter_declarator
-      && parameter_declarator->declarator
+  if (parameter_declarator->declarator
       && parameter_declarator->declarator->parameter_pack_p)
     {
       *is_parameter_pack = true;
       parameter_declarator->declarator->parameter_pack_p = false;
     }
 
-  if (parameter_declarator
-      && parameter_declarator->default_argument)
+  if (parameter_declarator->default_argument)
     {
       /* Can happen in some cases of erroneous input (c++/34892).  */
       if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
@@ -13014,8 +13015,7 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type,
   /* We might end up with a pack expansion as the type of the non-type
      template parameter, in which case this is a non-type template
      parameter pack.  */
-  else if (parameter_declarator
-          && parameter_declarator->decl_specifiers.type
+  else if (parameter_declarator->decl_specifiers.type
           && PACK_EXPANSION_P (parameter_declarator->decl_specifiers.type))
     {
       *is_parameter_pack = true;
index f0c4804341297ae9de8be7fd08a0c07d18a8689b..a56b69dbb64e53c84ea66e62e199bf5a1064ce60 100644 (file)
@@ -1,7 +1,9 @@
 2014-01-06  Adam Butcher  <adam@jessamine.co.uk>
 
        PR c++/59635
+       PR c++/59636
        * g++.dg/cpp1y/pr59635.C: New testcase.
+       * g++.dg/cpp1y/pr59636.C: New testcase.
 
 2014-01-06  Martin Jambor  <mjambor@suse.cz>
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59636.C b/gcc/testsuite/g++.dg/cpp1y/pr59636.C
new file mode 100644 (file)
index 0000000..f2ca5b6
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+// PR c++/59636
+
+auto f = []() { return []<>() {}; };  // { dg-error "expected identifier" }
+