diff options
author | Alan Zhao <alanzhao1@users.noreply.github.com> | 2024-01-18 10:53:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 10:53:54 -0800 |
commit | 2c9f04c98a1922d711fd1a88563506ee75c771bf (patch) | |
tree | 7f1993bc44430c6ea9f8bf2bea335519c27c6617 /clang/lib/Sema/SemaInit.cpp | |
parent | 5de1d007ddc5b13a643ebedce42c5c164cd3bec2 (diff) | |
download | llvm-2c9f04c98a1922d711fd1a88563506ee75c771bf.zip llvm-2c9f04c98a1922d711fd1a88563506ee75c771bf.tar.gz llvm-2c9f04c98a1922d711fd1a88563506ee75c771bf.tar.bz2 |
[clang] Fix parenthesized list initialization of arrays not working with `new` (#76976)
This bug is caused by parenthesized list initialization not being
implemented in `CodeGenFunction::EmitNewArrayInitializer(...)`.
Parenthesized list initialization of `struct`s with `operator new`
already works in Clang and is not affected by this bug.
Additionally, fix the test new-delete.cpp as it incorrectly assumes that
using parentheses with operator new to initialize arrays is illegal for
C++ versions >= C++17.
Fixes #68198
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 96900ef..18440a6 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5496,7 +5496,7 @@ static void TryOrBuildParenListInitialization( return; } // ...and value-initialized for each k < i <= n; - if (ArrayLength > Args.size()) { + if (ArrayLength > Args.size() || Entity.isVariableLengthArrayNew()) { InitializedEntity SubEntity = InitializedEntity::InitializeElement( S.getASTContext(), Args.size(), Entity); InitializationKind SubKind = InitializationKind::CreateValue( |