]> granicus.if.org Git - clang/commitdiff
Don't allow non-empty ParenListExprs as array-new initializers.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 17 Feb 2012 08:42:32 +0000 (08:42 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 17 Feb 2012 08:42:32 +0000 (08:42 +0000)
Don't know what I was thinking there. Fixes PR12023.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150804 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/new-delete.cpp

index 1f50984996ae36c150469af02536769883eac282..ca8411918a7d79244027595201cc921ba727b542 100644 (file)
@@ -981,11 +981,8 @@ static bool isLegalArrayNewInitializer(CXXNewExpr::InitializationStyle Style,
                                        Expr *Init) {
   if (!Init)
     return true;
-  if (ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
-    if (PLE->getNumExprs() != 1)
-      return PLE->getNumExprs() == 0;
-    Init = PLE->getExpr(0);
-  }
+  if (ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init))
+    return PLE->getNumExprs() == 0;
   if (isa<ImplicitValueInitExpr>(Init))
     return true;
   else if (CXXConstructExpr *CCE = dyn_cast<CXXConstructExpr>(Init))
index dfe880e34bb8b503d73f115b77923de90332d945..d355c7cc51a91b71f91ce0599099a5afd17963a0 100644 (file)
@@ -446,3 +446,17 @@ namespace r150682 {
   }
 
 }
+
+namespace P12023 {
+  struct CopyCounter
+  {
+      CopyCounter();
+      CopyCounter(const CopyCounter&);
+  };
+
+  int main()
+  {
+    CopyCounter* f = new CopyCounter[10](CopyCounter()); // expected-error {{cannot have initialization arguments}}
+      return 0;
+  }
+}