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 52400421d6419df7d1d982da0b2b0571f2866a53..c921f203ac993b34692be4988a2a5b864a9d9304 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 2a2cbf0f0610715d2afdadb40c7bbf29fa753ab8..4ef0f05c9bebd50f27ccf16b5d984dddaf671961 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" }
+}