From f8221c67ba78dff0d80fb5f9d9d3edfa5d842735 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 2 Mar 2011 13:18:41 -0500 Subject: [PATCH] re PR c++/46159 (Bogus warning about lambdas) PR c++/46159 * parser.c (cp_parser_primary_expression): Don't warn about a failed tentative parse. From-SVN: r170621 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/parser.c | 10 ++++++++-- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C | 8 ++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a5244f364e..a080431ff87 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Jason Merrill + 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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 314a2ff2c49..c63d5b3a049 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 ()) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ac00aa9f66..c4f8ceeacfb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-03-01 Jason Merrill + * g++.dg/cpp0x/lambda/lambda-98.C: New. + * g++.dg/cpp0x/constexpr-non-const-arg2.C: New. 2011-03-02 Richard Sandiford 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 index 00000000000..ff1085f30c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C @@ -0,0 +1,8 @@ +// PR c++/46159 +// { dg-options -std=c++98 } + +void +f() +{ + int **p = new(int(*[2])); +} -- 2.30.2