diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-25 05:18:00 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-25 05:18:00 +0000 |
commit | fe2de492d00c9698e2f98568bbb72964d50ed467 (patch) | |
tree | 79e263571848b4b4787b41d8664207fa3d69588d | |
parent | da3f4e2dd5938145f132be237a2ed5914cc86702 (diff) |
InitializeVarWithConstructor now returns true on failure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79976 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 12 |
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index a60c60c4e1..363f3ade79 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1747,7 +1747,7 @@ public: /// 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); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6668aeaac5..99c1338fba 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3257,8 +3257,11 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, 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); } } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 17e88b3512..f4b5a57ed5 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2467,18 +2467,21 @@ Sema::BuildCXXConstructExpr(QualType DeclInitType, 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) @@ -2555,8 +2558,9 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, 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; |