mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-21 20:45:53 -04:00
Value initialize non-class array members in ctor's
initializer list. Fixes PR5463. llvm-svn: 86849
This commit is contained in:
parent
7a09964e81
commit
03f62ed9bb
@ -1511,7 +1511,14 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
|
|||||||
RHS = RValue::get(CGF.CGM.EmitConstantExpr(RhsExpr, FieldType, &CGF));
|
RHS = RValue::get(CGF.CGM.EmitConstantExpr(RhsExpr, FieldType, &CGF));
|
||||||
else
|
else
|
||||||
RHS = RValue::get(CGF.EmitScalarExpr(RhsExpr, true));
|
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
|
/// EmitCtorPrologue - This routine generates necessary code to initialize
|
||||||
|
28
clang/test/CodeGenCXX/array-value-initialize.cpp
Normal file
28
clang/test/CodeGenCXX/array-value-initialize.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// RUN: clang-cc -emit-llvm -o - %s
|
||||||
|
|
||||||
|
// PR5463
|
||||||
|
extern "C" int printf(...);
|
||||||
|
|
||||||
|
struct S {
|
||||||
|
double filler;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
Foo(void) : bar_(), dbar_(), sbar_() {
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
printf("bar_[%d] = %d\n", i, bar_[i]);
|
||||||
|
printf("dbar_[%d] = %f\n", i, dbar_[i]);
|
||||||
|
printf("sbar_[%d].filler = %f\n", i, sbar_[i].filler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int bar_[5];
|
||||||
|
double dbar_[5];
|
||||||
|
S sbar_[5];
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
Foo a;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user