re PR c++/43886 ([C++0x] name lookup failure on un-used local variable in lambda...
authorJason Merrill <jason@redhat.com>
Tue, 2 Aug 2011 21:09:26 +0000 (17:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 2 Aug 2011 21:09:26 +0000 (17:09 -0400)
PR c++/43886
* parser.c (cp_parser_lambda_body): Clear local_variables_forbidden_p.

From-SVN: r177216

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

index 4e64f1bae1d8b2d3796342ed307816c5737b8b14..1c50f0424eec8b07249e7203eb9151b22a8fd44f 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43886
+       * parser.c (cp_parser_lambda_body): Clear local_variables_forbidden_p.
+
        PR c++/49577
        * typeck2.c (check_narrowing): Check unsigned mismatch.
        * semantics.c (finish_compound_literal): check_narrowing.
index 2d8f457e737926896ff9e723c25ac082bf210e01..9b3e56d07f43d2abd1f61c50cf6b88878f706473 100644 (file)
@@ -7801,12 +7801,15 @@ static void
 cp_parser_lambda_body (cp_parser* parser, tree lambda_expr)
 {
   bool nested = (current_function_decl != NULL_TREE);
+  bool local_variables_forbidden_p = parser->local_variables_forbidden_p;
   if (nested)
     push_function_context ();
   else
     /* Still increment function_depth so that we don't GC in the
        middle of an expression.  */
     ++function_depth;
+  /* Clear this in case we're in the middle of a default argument.  */
+  parser->local_variables_forbidden_p = false;
 
   /* Finish the function call operator
      - class_specifier
@@ -7904,6 +7907,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr)
     expand_or_defer_fn (finish_function (/*inline*/2));
   }
 
+  parser->local_variables_forbidden_p = local_variables_forbidden_p;
   if (nested)
     pop_function_context();
   else
index 6e91668b990611a5cd9e02faae5299b23cc67505..4c8f25cb9ef5581ddce08a5d4a19016af1e058a6 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43886
+       * g++.dg/cpp0x/lambda/lambda-defarg2.C: New.
+
        PR c++/49577
        * g++.dg/cpp0x/initlist5.C: Add additional cases.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg2.C
new file mode 100644 (file)
index 0000000..f47c5ba
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/43886
+// { dg-options -std=c++0x }
+
+void f2() {
+  int i = 1;
+  void g5(int = ([]{ return sizeof i; })());
+}