Value initialize non-class array members in ctor's
initializer list. Fixes PR5463.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86849 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 40e90ee..3e9951f 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -1511,7 +1511,14 @@
RHS = RValue::get(CGF.CGM.EmitConstantExpr(RhsExpr, FieldType, &CGF));
else
RHS = RValue::get(CGF.EmitScalarExpr(RhsExpr, true));
- CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
+ if (Array && !FieldType->getAs<RecordType>()) {
+ // value initialize a non-class array data member using arr() syntax in
+ // initializer list.
+ QualType Ty = CGF.getContext().getCanonicalType((Field)->getType());
+ CGF.EmitMemSetToZero(LHS.getAddress(), Ty);
+ }
+ else
+ CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
}
/// EmitCtorPrologue - This routine generates necessary code to initialize