Skip to content

Fix an error introduced in #138518 #142988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,10 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
assert(InitStyle == CXXNewInitializationStyle::Parens &&
"paren init for non-call init");
Exprs = MultiExprArg(List->getExprs(), List->getNumExprs());
} else if (auto *List = dyn_cast_or_null<CXXParenListInitExpr>(Initializer)) {
assert(InitStyle == CXXNewInitializationStyle::Parens &&
"paren init for non-call init");
Exprs = List->getInitExprs();
}

// C++11 [expr.new]p15:
Expand Down
23 changes: 23 additions & 0 deletions clang/test/SemaCXX/paren-list-init-expr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-dump %s | FileCheck %s
struct Node {
long val;
};
template <bool>
void CallNew() {
new Node(0);
}
// CHECK-LABEL: FunctionTemplateDecl {{.*}} CallNew
// CHECK: |-FunctionDecl {{.*}} CallNew 'void ()'
// CHECK: `-CXXNewExpr {{.*}} 'operator new'
// CHECK: `-CXXParenListInitExpr {{.*}} 'Node'
// CHECK: `-ImplicitCastExpr {{.*}} 'long' <IntegralCast>
// CHECK: `-IntegerLiteral {{.*}} 'int' 0
// CHECK: `-FunctionDecl {{.*}} used CallNew 'void ()' implicit_instantiation
// CHECK: |-TemplateArgument integral 'true'
// CHECK: `-CXXNewExpr {{.*}} 'operator new'
// CHECK: `-CXXParenListInitExpr {{.*}} 'Node'
// CHECK: `-ImplicitCastExpr {{.*}} 'long' <IntegralCast>
// CHECK: `-IntegerLiteral {{.*}} 'int' 0
void f() {
(void)CallNew<true>;
}
Loading