/// InitializeVarWithConstructor - Creates an CXXConstructExpr
/// and sets it as the initializer for the the passed in VarDecl.
- void InitializeVarWithConstructor(VarDecl *VD,
+ bool InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
QualType DeclInitType,
Expr **Exprs, unsigned NumExprs);
if (!Constructor)
Var->setInvalidDecl();
else {
- if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor())
- InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0);
+ if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor()) {
+ if (InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0))
+ Var->setInvalidDecl();
+ }
+
FinalizeVarWithDestructor(Var, InitType);
}
}
return Owned(Temp);
}
-void Sema::InitializeVarWithConstructor(VarDecl *VD,
+bool Sema::InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
QualType DeclInitType,
Expr **Exprs, unsigned NumExprs) {
OwningExprResult TempResult = BuildCXXConstructExpr(DeclInitType, Constructor,
Exprs, NumExprs);
- assert(!TempResult.isInvalid() && "FIXME: Error handling");
+ if (TempResult.isInvalid())
+ return true;
Expr *Temp = TempResult.takeAs<Expr>();
MarkDeclarationReferenced(VD->getLocation(), Constructor);
Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
VD->setInit(Context, Temp);
+
+ return false;
}
void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType)
RealDecl->setInvalidDecl();
else {
VDecl->setCXXDirectInitializer(true);
- InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
- (Expr**)Exprs.release(), NumExprs);
+ if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
+ (Expr**)Exprs.release(), NumExprs))
+ RealDecl->setInvalidDecl();
FinalizeVarWithDestructor(VDecl, DeclInitType);
}
return;