]> granicus.if.org Git - clang/commitdiff
Add an extra check for invalid decls in the lambda semantic analysis to avoid a crash...
authorEli Friedman <eli.friedman@gmail.com>
Tue, 18 Sep 2012 21:11:30 +0000 (21:11 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 18 Sep 2012 21:11:30 +0000 (21:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164168 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 75ea5368f86c0de2369387f50b3eceb4de1a59ce..7cbfc364f66679d85fbf1d6972267ab1f50c0664 100644 (file)
@@ -527,6 +527,10 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
       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;
index 0fd634502bc9cd8137ec9a2167f462382a3b8085..0a95680478d19ac02b5ae9d00b34a305f357abac 100644 (file)
@@ -221,3 +221,11 @@ namespace VariadicPackExpansion {
   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), "");
+  }
+}