]> granicus.if.org Git - clang/commitdiff
Use EmitStoreOfScalar when copying the scalar to the space allocated by 'new'.
authorAnders Carlsson <andersca@mac.com>
Sun, 22 Nov 2009 19:25:33 +0000 (19:25 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 22 Nov 2009 19:25:33 +0000 (19:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89613 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXXExpr.cpp
test/CodeGenCXX/new.cpp

index 409296f7161a26442546ae8af42aaaab8cbb5bc7..845669d402119621e3dbde45c665066d7f0d1fcb 100644 (file)
@@ -103,8 +103,9 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
       
     const Expr *Init = E->getConstructorArg(0);
     
-    if (!CGF.hasAggregateLLVMType(AllocType))
-      CGF.Builder.CreateStore(CGF.EmitScalarExpr(Init), NewPtr);
+    if (!CGF.hasAggregateLLVMType(AllocType)) 
+      CGF.EmitStoreOfScalar(CGF.EmitScalarExpr(Init), NewPtr,
+                        AllocType.isVolatileQualified(), AllocType);
     else if (AllocType->isAnyComplexType())
       CGF.EmitComplexExprIntoAddr(Init, NewPtr, 
                                   AllocType.isVolatileQualified());
index 3f191de23bcff5240f1c17e6133afec7f1d1d8e5..ddf1f9b3c904d75cd6ed396001598274b81eafbb 100644 (file)
@@ -72,3 +72,10 @@ void t8(int n) {
   new U[10];
   new U[n];
 }
+
+void t9() {
+  bool b;
+
+  new bool(true);  
+  new (&b) bool(true);
+}