diff options
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 20 | 
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 49bbb4808eaa..a05a088f0919 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -512,12 +512,20 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,      currentElement->addIncoming(element, entryBB);      // Emit the actual filler expression. -    LValue elementLV = -      CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType); -    if (filler) -      EmitInitializationToLValue(filler, elementLV); -    else -      EmitNullInitializationToLValue(elementLV); +    { +      // C++1z [class.temporary]p5: +      //   when a default constructor is called to initialize an element of +      //   an array with no corresponding initializer [...] the destruction of +      //   every temporary created in a default argument is sequenced before +      //   the construction of the next array element, if any +      CodeGenFunction::RunCleanupsScope CleanupsScope(CGF); +      LValue elementLV = +        CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType); +      if (filler) +        EmitInitializationToLValue(filler, elementLV); +      else +        EmitNullInitializationToLValue(elementLV); +    }      // Move on to the next element.      llvm::Value *nextElement =  | 
