From 03f62ed9bb386058126776589194d3bf8a72b19b Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 11 Nov 2009 17:55:25 +0000 Subject: Value initialize non-class array members in ctor's initializer list. Fixes PR5463. llvm-svn: 86849 --- clang/lib/CodeGen/CGCXX.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CGCXX.cpp') diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 40e90ee..3e9951f 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -1511,7 +1511,14 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, 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()) { + // 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 -- cgit v1.1