commit 9b7a53bda8938ff42074b1f38a3e0b68cb37e52e Author: Jason Merrill Date: Sat Apr 9 01:40:20 2011 -0400 PR c++/48523 * tree.c (maybe_dummy_object): Use build_x_indirect_ref rather than cp_build_indirect_ref. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d6b6197..ad004bb 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2423,7 +2423,7 @@ maybe_dummy_object (tree type, tree* binfop) else if (current != current_class_type && context == nonlambda_method_basetype ()) /* In a lambda, need to go through 'this' capture. */ - decl = (cp_build_indirect_ref + decl = (build_x_indirect_ref ((lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (current_class_type))), RO_NULL, tf_warning_or_error)); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C new file mode 100644 index 0000000..29cd2a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C @@ -0,0 +1,13 @@ +// PR c++/48523 +// { dg-options -std=c++0x } + +template +struct X +{ + bool b; + + void f() + { + [this]{ return b; }; + } +};