diff options
-rw-r--r-- | include/clang/AST/ExprCXX.h | 3 | ||||
-rw-r--r-- | lib/AST/ExprCXX.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 3 | ||||
-rw-r--r-- | test/CodeGenCXX/value-init.cpp | 26 |
4 files changed, 33 insertions, 4 deletions
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index d66642c1ad..d26efa7296 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -784,7 +784,8 @@ public: CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, QualType writtenTy, SourceLocation tyBeginLoc, Expr **Args,unsigned NumArgs, - SourceLocation rParenLoc); + SourceLocation rParenLoc, + bool ZeroInitialization = false); ~CXXTemporaryObjectExpr() { } diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index c394e476f8..592d887d31 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -459,9 +459,10 @@ CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C, SourceLocation tyBeginLoc, Expr **Args, unsigned NumArgs, - SourceLocation rParenLoc) + SourceLocation rParenLoc, + bool ZeroInitialization) : CXXConstructExpr(C, CXXTemporaryObjectExprClass, writtenTy, tyBeginLoc, - Cons, false, Args, NumArgs), + Cons, false, Args, NumArgs, ZeroInitialization), TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) { } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 1caa94bf81..4678822413 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3745,7 +3745,8 @@ InitializationSequence::Perform(Sema &S, Kind.getLocation(), Exprs, NumExprs, - Kind.getParenRange().getEnd())); + Kind.getParenRange().getEnd(), + ConstructorInitRequiresZeroInit)); } else CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(), Constructor, diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp index 37891bd6af..35be159aac 100644 --- a/test/CodeGenCXX/value-init.cpp +++ b/test/CodeGenCXX/value-init.cpp @@ -23,3 +23,29 @@ void test_value_init() { C c = { 17 } ; // CHECK: call void @_ZN1CD1Ev } + +enum enum_type { negative_number = -1, magic_number = 42 }; + +class enum_holder +{ + enum_type m_enum; + +public: + enum_holder() : m_enum(magic_number) { } +}; + +struct enum_holder_and_int +{ + enum_holder e; + int i; +}; + +// CHECK: _Z24test_enum_holder_and_intv() +void test_enum_holder_and_int() { + // CHECK: alloca + // CHECK-NEXT: bitcast + // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: call void @_ZN19enum_holder_and_intC1Ev + enum_holder_and_int(); + // CHECK-NEXT: ret void +} |