const Expr *Init = E->getInitializer();
const InitListExpr *ResizedArrayILE = nullptr;
const CXXConstructExpr *ResizedArrayCCE = nullptr;
+ bool ValueInit = false;
QualType AllocType = E->getAllocatedType();
if (Optional<const Expr*> ArraySize = E->getArraySize()) {
// -- the new-initializer is a braced-init-list and the number of
// array elements for which initializers are provided [...]
// exceeds the number of elements to initialize
- if (Init && !isa<CXXConstructExpr>(Init)) {
+ if (!Init) {
+ // No initialization is performed.
+ } else if (isa<CXXScalarValueInitExpr>(Init) ||
+ isa<ImplicitValueInitExpr>(Init)) {
+ ValueInit = true;
+ } else if (auto *CCE = dyn_cast<CXXConstructExpr>(Init)) {
+ ResizedArrayCCE = CCE;
+ } else {
auto *CAT = Info.Ctx.getAsConstantArrayType(Init->getType());
assert(CAT && "unexpected type for array initializer");
// special handling for this case when we initialize.
if (InitBound != AllocBound)
ResizedArrayILE = cast<InitListExpr>(Init);
- } else if (Init) {
- ResizedArrayCCE = cast<CXXConstructExpr>(Init);
}
AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
return false;
}
- if (ResizedArrayILE) {
+ if (ValueInit) {
+ ImplicitValueInitExpr VIE(AllocType);
+ if (!EvaluateInPlace(*Val, Info, Result, &VIE))
+ return false;
+ } else if (ResizedArrayILE) {
if (!EvaluateArrayNewInitList(Info, Result, *Val, ResizedArrayILE,
AllocType))
return false;