[clang] Reapply "[Clang][Sema] placement new initializes typedef array with correct size (#83124)" (PR #89036)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 19 06:38:19 PDT 2024


================
@@ -12864,6 +12864,19 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
     ArraySize = NewArraySize.get();
   }
 
+  // Per C++0x [expr.new]p5, the type being constructed may be a
+  // typedef of an array type.
+  QualType AllocType = AllocTypeInfo->getType();
+  if (ArraySize && E->isTypeDependent()) {
----------------
mahtohappy wrote:

Yes, it does. Both the original testcase from @slackito  and simpler version of @dwblaikie are working now. 
normal arrays with new initializer also were passing the check and their type was correct earlier so need for modification for them. ```typedef TYPE TArray[8]; TArray x;``` here type of array was Tarray which should be Type* so the check only for type dependent case. 

https://github.com/llvm/llvm-project/pull/89036


More information about the cfe-commits mailing list