[cfe-commits] r164168 - in /cfe/trunk: lib/Sema/SemaLambda.cpp test/SemaCXX/lambda-expressions.cpp

Eli Friedman eli.friedman at gmail.com
Tue Sep 18 14:11:30 PDT 2012


Author: efriedma
Date: Tue Sep 18 16:11:30 2012
New Revision: 164168

URL: http://llvm.org/viewvc/llvm-project?rev=164168&view=rev
Log:
Add an extra check for invalid decls in the lambda semantic analysis to avoid a crash.  PR13860.


Modified:
    cfe/trunk/lib/Sema/SemaLambda.cpp
    cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=164168&r1=164167&r2=164168&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Tue Sep 18 16:11:30 2012
@@ -527,6 +527,10 @@
       continue;
     }
 
+    // Ignore invalid decls; they'll just confuse the code later.
+    if (Var->isInvalidDecl())
+      continue;
+
     if (!Var->hasLocalStorage()) {
       Diag(C->Loc, diag::err_capture_non_automatic_variable) << C->Id;
       Diag(Var->getLocation(), diag::note_previous_decl) << C->Id;

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=164168&r1=164167&r2=164168&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Tue Sep 18 16:11:30 2012
@@ -221,3 +221,11 @@
   template void nested2(int); // ok
   template void nested2(int, int); // expected-note {{in instantiation of}}
 }
+
+namespace PR13860 {
+  void foo() {
+    auto x = PR13860UndeclaredIdentifier(); // expected-error {{use of undeclared identifier 'PR13860UndeclaredIdentifier'}}
+    auto y = [x]() { };
+    static_assert(sizeof(y), "");
+  }
+}





More information about the cfe-commits mailing list