[clang] [clang] Fix parenthesized list initialization of arrays not working with `new` (PR #76976)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 12:16:02 PST 2024


================
@@ -1038,11 +1038,14 @@ void CodeGenFunction::EmitNewArrayInitializer(
     return true;
   };
 
+  const InitListExpr *ILE = dyn_cast<InitListExpr>(Init);
+  const CXXParenListInitExpr *CPLIE = dyn_cast<CXXParenListInitExpr>(Init);
+  const StringLiteral *SL = dyn_cast<StringLiteral>(Init);
   // If the initializer is an initializer list, first do the explicit elements.
-  if (const InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
+  if (ILE || CPLIE || SL) {
----------------
efriedma-quic wrote:

Sure, but have you tried, for example, `char* x = new char[](__extension__ "asdf");`.  Or in objective-c++ mode, `char* x = new char[](@encode(int));`

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


More information about the cfe-commits mailing list