re PR c++/46159 (Bogus warning about lambdas)
authorJason Merrill <jason@redhat.com>
Wed, 2 Mar 2011 18:18:41 +0000 (13:18 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 2 Mar 2011 18:18:41 +0000 (13:18 -0500)
PR c++/46159
* parser.c (cp_parser_primary_expression): Don't warn about a
failed tentative parse.

From-SVN: r170621

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

index 2a5244f364e903e22ea869fb18cf908044093037..a080431ff877a4c6988d38f15eea8a167653199c 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-01  Jason Merrill  <jason@redhat.com>
 
+       PR c++/46159
+       * parser.c (cp_parser_primary_expression): Don't warn about a
+       failed tentative parse.
+
        PR c++/47200
        * semantics.c (cxx_bind_parameters_in_call): Don't call
        adjust_temp_type on non-constant args.
index 314a2ff2c49703d655354aac38aeb71e90e9bff1..c63d5b3a0498f536c6dfb9a6fb509d902d46a07f 100644 (file)
@@ -3712,8 +3712,14 @@ cp_parser_primary_expression (cp_parser *parser,
       if (c_dialect_objc ())
         /* We have an Objective-C++ message. */
         return cp_parser_objc_expression (parser);
-      maybe_warn_cpp0x (CPP0X_LAMBDA_EXPR);
-      return cp_parser_lambda_expression (parser);
+      {
+       tree lam = cp_parser_lambda_expression (parser);
+       /* Don't warn about a failed tentative parse.  */
+       if (cp_parser_error_occurred (parser))
+         return error_mark_node;
+       maybe_warn_cpp0x (CPP0X_LAMBDA_EXPR);
+       return lam;
+      }
 
     case CPP_OBJC_STRING:
       if (c_dialect_objc ())
index 1ac00aa9f661f846050146e9ea72e56c5f6f0ad0..c4f8ceeacfb430daefc9592983d739a9b513e5c5 100644 (file)
@@ -1,5 +1,7 @@
 2011-03-01  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/lambda/lambda-98.C: New.
+
        * g++.dg/cpp0x/constexpr-non-const-arg2.C: New.
 
 2011-03-02  Richard Sandiford  <richard.sandiford@linaro.org>
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C
new file mode 100644 (file)
index 0000000..ff1085f
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/46159
+// { dg-options -std=c++98 }
+
+void
+f()
+{
+  int **p = new(int(*[2]));
+}