PR c++/70781 - ICE on ill-formed lambda.
authorJason Merrill <jason@redhat.com>
Thu, 21 Jul 2016 06:05:58 +0000 (02:05 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 Jul 2016 06:05:58 +0000 (02:05 -0400)
* parser.c (cp_parser_lambda_expression): Unset OK if there was an
error parsing the lambda-declarator.

From-SVN: r238563

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

index 78487eac174a14da264270737c8ac8c82b321bdd..2e8877faef9f287b7dbf599dad446053e4a4e7e7 100644 (file)
@@ -1,5 +1,9 @@
 2016-07-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/70781
+       * parser.c (cp_parser_lambda_expression): Unset OK if there was an
+       error parsing the lambda-declarator.
+
        PR c++/71896
        * constexpr.c (cxx_eval_binary_expression): Handle comparison
        between lowered and unlowered PTRMEM_CST.
index 9bdb10894184bca9fa9eaacb605067ce05890bcd..b71b9e5ac427d12d91936563ad625f5d3fddb79e 100644 (file)
@@ -9771,10 +9771,12 @@ cp_parser_lambda_expression (cp_parser* parser)
 
     ok &= cp_parser_lambda_declarator_opt (parser, lambda_expr);
 
+    if (ok && cp_parser_error_occurred (parser))
+      ok = false;
+
     if (ok)
       {
-       if (!cp_parser_error_occurred (parser)
-           && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)
+       if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)
            && cp_parser_start_tentative_firewall (parser))
          start = token;
        cp_parser_lambda_body (parser, lambda_expr);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice16.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice16.C
new file mode 100644 (file)
index 0000000..e94a0b6
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/70781
+// { dg-do compile { target c++11 } }
+
+template < typename T >  
+void foo ()
+{
+  T ([=] (S) { [=] {}; });     // { dg-error "" }
+}