re PR c++/59349 (ICE on invalid: Segmentation fault toplev.c:336)
authorJason Merrill <jason@redhat.com>
Tue, 24 Dec 2013 04:22:15 +0000 (23:22 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 24 Dec 2013 04:22:15 +0000 (23:22 -0500)
PR c++/59349
* parser.c (cp_parser_lambda_introducer): Handle empty init.

From-SVN: r206192

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

index 5240042..c921f20 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/59349
+       * parser.c (cp_parser_lambda_introducer): Handle empty init.
+
 2013-12-23  Stuart Hastings <stuart@apple.com>
            Bill Maddox  <maddox@google.com>
            Jason Merrill  <jason@redhat.com>
index 2a2cbf0..4ef0f05 100644 (file)
@@ -8898,6 +8898,11 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
          capture_init_expr = cp_parser_initializer (parser, &direct,
                                                     &non_constant);
          explicit_init_p = true;
+         if (capture_init_expr == NULL_TREE)
+           {
+             error ("empty initializer for lambda init-capture");
+             capture_init_expr = error_mark_node;
+           }
        }
       else
        {
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C
new file mode 100644 (file)
index 0000000..ad152cf
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/59349
+// { dg-options "-std=c++1y" }
+
+int foo () {
+  [bar()]{};                   // { dg-error "empty initializer" }
+}