declaration, ensure the loop variable is properly marked as invalid when
it is an "auto" variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236682
91177308-0d34-0410-b5e6-
96231b3b80d8
/// \return true if an error occurs.
static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init,
SourceLocation Loc, int DiagID) {
+ if (Decl->getType()->isUndeducedType()) {
+ ExprResult Res = SemaRef.CorrectDelayedTyposInExpr(Init);
+ if (!Res.isUsable()) {
+ Decl->setInvalidDecl();
+ return true;
+ }
+ Init = Res.get();
+ }
+
// Deduce the type for the iterator variable now rather than leaving it to
// AddInitializerToDecl, so we can produce a more suitable diagnostic.
QualType InitType;
int thatval = aaa * (bbb + thatvar); // expected-error {{use of undeclared identifier 'thatvar'; did you mean 'thisvar'?}}
}
}
+
+namespace PR18854 {
+void f() {
+ for (auto&& x : e) { // expected-error-re {{use of undeclared identifier 'e'{{$}}}}
+ auto Functor = [x]() {};
+ long Alignment = __alignof__(Functor);
+ }
+}
+}