Skip to content

Commit 20506a0

Browse files
authored
[clang][bytecode] Fix operator new source expression (#126870)
... for composite element types. Looks like I forgot this in e6030d3
1 parent 25c0554 commit 20506a0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
16831683
assert(!ElemT);
16841684
// Structs etc.
16851685
const Descriptor *Desc = S.P.createDescriptor(
1686-
Call, ElemType.getTypePtr(), Descriptor::InlineDescMD,
1686+
NewCall, ElemType.getTypePtr(), Descriptor::InlineDescMD,
16871687
/*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
16881688
/*Init=*/nullptr);
16891689

clang/test/AST/ByteCode/new-delete.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,17 @@ template <typename T>
840840
struct SS {
841841
constexpr SS(unsigned long long N)
842842
: data(nullptr){
843-
data = alloc.allocate(N); // #call
843+
data = alloc.allocate(N);
844844
for(std::size_t i = 0; i < N; i ++)
845-
std::construct_at<T>(data + i, i); // #construct_call
845+
std::construct_at<T>(data + i, i);
846846
}
847+
848+
constexpr SS()
849+
: data(nullptr){
850+
data = alloc.allocate(1);
851+
std::construct_at<T>(data);
852+
}
853+
847854
constexpr T operator[](std::size_t i) const {
848855
return data[i];
849856
}
@@ -855,6 +862,7 @@ struct SS {
855862
T* data;
856863
};
857864
constexpr unsigned short ssmall = SS<unsigned short>(100)[42];
865+
constexpr auto Ss = SS<S>()[0];
858866

859867

860868

0 commit comments

Comments
 (0)