]> granicus.if.org Git - clang/commitdiff
Make array new on a pointer to data member type work correctly. PR11523.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 9 Dec 2011 23:05:37 +0000 (23:05 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 9 Dec 2011 23:05:37 +0000 (23:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146291 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ed7605e34b852c36c6462278647f0ae30f82c82d..3f25806155f6e7283fc0e215f0c6f9ac01fbf3e5 100644 (file)
@@ -828,7 +828,7 @@ CodeGenFunction::EmitNewArrayInitializer(const CXXNewExpr *E,
   StoreAnyExprIntoOneUnit(*this, E, curPtr);
 
   // Leave the cleanup if we entered one.
-  if (cleanup != EHStack.stable_end()) {
+  if (cleanupDominator) {
     DeactivateCleanupBlock(cleanup, cleanupDominator);
     cleanupDominator->eraseFromParent();
   }
@@ -883,7 +883,8 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
                                      RequiresZeroInitialization);
       return;
     } else if (E->getNumConstructorArgs() == 1 &&
-               isa<ImplicitValueInitExpr>(E->getConstructorArg(0))) {
+               isa<ImplicitValueInitExpr>(E->getConstructorArg(0)) &&
+               CGF.CGM.getTypes().isZeroInitializable(ElementType)) {
       // Optimization: since zero initialization will just set the memory
       // to all zeroes, generate a single memset to do it in one shot.
       EmitZeroMemSet(CGF, ElementType, NewPtr, AllocSizeWithoutCookie);
index 3a72bb84e7f65300563e17a234e069920eff35fe..810a585bca5c009661b9d4b0845d8bd513679312 100644 (file)
@@ -231,3 +231,11 @@ namespace PR10197 {
 
   template void f<int>();
 }
+
+namespace PR11523 {
+  class MyClass;
+  typedef int MyClass::* NewTy;
+  // CHECK: define i64* @_ZN7PR115231fEv
+  // CHECK: store i64 -1
+  NewTy* f() { return new NewTy[2](); }
+}