]> granicus.if.org Git - clang/commitdiff
PR19249: Don't forget to DiagnoseUseOfDecl for the implicit use of a variable
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Mar 2014 21:11:32 +0000 (21:11 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Mar 2014 21:11:32 +0000 (21:11 +0000)
in a lambda capture.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLambda.cpp
test/SemaCXX/lambda-expressions.cpp

index cd62ba4b92dc68f29fcbce74dc7c7bee8dd622c4..0d287f7210cf7955aaae5d6450b64a266f33bc04 100644 (file)
@@ -1062,6 +1062,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
       }
 
       Var = R.getAsSingle<VarDecl>();
+      if (Var && DiagnoseUseOfDecl(Var, C->Loc))
+        continue;
     }
 
     // C++11 [expr.prim.lambda]p8:
index 8bacc0aa6466bb7d65bf901b44f99e79782cb259..9a53e4604f76341909e472b2a3d37c6af0e867c2 100644 (file)
@@ -359,3 +359,7 @@ namespace PR18473 {
   };
   template void f<NoCopy>(); // expected-note {{instantiation}}
 }
+
+void PR19249() {
+  auto x = [&x]{}; // expected-error {{cannot appear in its own init}}
+}