-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Conversation
@llvm/pr-subscribers-clang Author: Alexander Kornienko (alexfh) ChangesCXXParenListInitExpr arguments would lose casts leading to incorrect types being Full diff: https://github.com/llvm/llvm-project/pull/142988.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 84521a3f80ff4..516015302bb39 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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
diff --git a/clang/test/SemaCXX/paren-list-init-expr.cpp b/clang/test/SemaCXX/paren-list-init-expr.cpp
new file mode 100644
index 0000000000000..7d7f46be7a8fd
--- /dev/null
+++ b/clang/test/SemaCXX/paren-list-init-expr.cpp
@@ -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>;
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 nit, else this LGTM. @cor3ntin should have a quick look, but I'm happy with this.
Thank you so much!
This fixes Windows CI.
@cor3ntin PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
CXXParenListInitExpr arguments would lose casts leading to incorrect types being used (e.g. only 32 bits of a 64 bit value being initialized). See llvm#138518 (comment) and llvm#138518 (comment) for details and context.
CXXParenListInitExpr arguments would lose casts leading to incorrect types being used (e.g. only 32 bits of a 64 bit value being initialized). See llvm#138518 (comment) and llvm#138518 (comment) for details and context.
CXXParenListInitExpr arguments would lose casts leading to incorrect types being used (e.g. only 32 bits of a 64 bit value being initialized). See #138518 (comment) and #138518 (comment) for details and context.