[clang] 7f1907c - [clang][bytecode] Allow bool sizes in array new expressions (#180696)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 10 00:27:21 PST 2026
Author: Timm Baeder
Date: 2026-02-10T09:27:17+01:00
New Revision: 7f1907cea06d0de861e94b607535fa6488641c15
URL: https://github.com/llvm/llvm-project/commit/7f1907cea06d0de861e94b607535fa6488641c15
DIFF: https://github.com/llvm/llvm-project/commit/7f1907cea06d0de861e94b607535fa6488641c15.diff
LOG: [clang][bytecode] Allow bool sizes in array new expressions (#180696)
Looks like this is a thing, so allow them.
Added:
Modified:
clang/lib/AST/ByteCode/Opcodes.td
clang/test/AST/ByteCode/new-delete.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td
index e701c954e00c2..b684b437dcbf7 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -877,13 +877,13 @@ def Alloc : Opcode {
}
def AllocN : Opcode {
- let Types = [IntegerTypeClass];
+ let Types = [IntegralTypeClass];
let Args = [ArgPrimType, ArgExpr, ArgBool];
let HasGroup = 1;
}
def AllocCN : Opcode {
- let Types = [IntegerTypeClass];
+ let Types = [IntegralTypeClass];
let Args = [ArgDesc, ArgBool];
let HasGroup = 1;
}
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index 419547239fa77..4e2af79a24811 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -17,6 +17,17 @@ static_assert(*(new int(12)) == 12); // both-error {{not an integral constant ex
static_assert((delete[] (new int[3] + 1), true)); // both-error {{not an integral constant expression}} \
// both-note {{delete of pointer to subobject '&{*new int[3]#0}[1]'}}
+struct S {
+ int a;
+ int b;
+
+ static constexpr S *create(int a, int b) {
+ return new S(a, b);
+ }
+};
+
+static_assert(((delete[] (new int[true])), true));
+static_assert(((delete[] (new S[true])), true));
constexpr int a() {
new int(12); // both-note {{allocation performed here was not deallocated}}
@@ -32,16 +43,6 @@ constexpr int b() {
}
static_assert(b() == 12, "");
-
-struct S {
- int a;
- int b;
-
- static constexpr S *create(int a, int b) {
- return new S(a, b);
- }
-};
-
constexpr int c() {
S *s = new S(12, 13);
More information about the cfe-commits
mailing list