Add an extra check for invalid decls in the lambda semantic analysis to avoid a crash. PR13860.

llvm-svn: 164168
This commit is contained in:
Eli Friedman 2012-09-18 21:11:30 +00:00
parent 87cdfaf895
commit e979db1583
2 changed files with 12 additions and 0 deletions

View 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;

View 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), "");
}
}