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

From-SVN: r170622

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 663d4caaaa6f81e5c44d435f7e7c997ccbdc4834..44dd46251def31a5328946712e8139b1d9e2383e 100644 (file)
@@ -1,3 +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.
+
 2011-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/47904
index f1f44d910c2d81ff2736d140db8c2383c3001a28..ca6eda75608953f955ade29ae2fe18fcf865b53a 100644 (file)
@@ -3341,8 +3341,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 14e8f40f143111047530cc98f44cca4364a130d6..421912e1386e1868d985fb1c37f5dc45229c6b0d 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-01  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/lambda/lambda-98.C: New.
+
 2011-03-02  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
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]));
+}