From: Richard Smith Date: Tue, 25 Mar 2014 21:11:32 +0000 (+0000) Subject: PR19249: Don't forget to DiagnoseUseOfDecl for the implicit use of a variable X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0733650b60a57b9fab2e1d8b3f26613fd4f46c53;p=clang PR19249: Don't forget to DiagnoseUseOfDecl for the implicit use of a variable in a lambda capture. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204757 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index cd62ba4b92..0d287f7210 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -1062,6 +1062,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, } Var = R.getAsSingle(); + if (Var && DiagnoseUseOfDecl(Var, C->Loc)) + continue; } // C++11 [expr.prim.lambda]p8: diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp index 8bacc0aa64..9a53e4604f 100644 --- a/test/SemaCXX/lambda-expressions.cpp +++ b/test/SemaCXX/lambda-expressions.cpp @@ -359,3 +359,7 @@ namespace PR18473 { }; template void f(); // expected-note {{instantiation}} } + +void PR19249() { + auto x = [&x]{}; // expected-error {{cannot appear in its own init}} +}