Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,11 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
"paren init for non-call init");
Exprs = MultiExprArg(List->getExprs(), List->getNumExprs());
}
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:
// A new-expression that creates an object of type T initializes that
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' 'void *(unsigned long)'
// 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' 'void *(unsigned long)'
// CHECK: `-CXXParenListInitExpr {{.*}} 'Node'
// CHECK: `-ImplicitCastExpr {{.*}} 'long' <IntegralCast>
// CHECK: `-IntegerLiteral {{.*}} 'int' 0
void f() {
(void)CallNew<true>;
}
Loading