Skip to content

Commit d4a2c7f

Browse files
committed
[clang][Interp] Fix record initialization from temporary in initlist
1 parent 7718ac3 commit d4a2c7f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,10 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
863863
assert(E->getType()->isRecordType());
864864
const Record *R = getRecord(E->getType());
865865

866+
if (Inits.size() == 1 && E->getType() == Inits[0]->getType()) {
867+
return this->visitInitializer(Inits[0]);
868+
}
869+
866870
unsigned InitIndex = 0;
867871
for (const Expr *Init : Inits) {
868872
if (!this->emitDupPtr(E))

clang/test/AST/Interp/records.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
// RUN: %clang_cc1 -verify=ref -std=c++20 %s
88
// RUN: %clang_cc1 -verify=ref -triple i686 %s
99

10+
/// Used to crash.
11+
struct Empty {};
12+
constexpr Empty e = {Empty()};
13+
1014
struct BoolPair {
1115
bool first;
1216
bool second;

clang/test/SemaCXX/cxx1z-copy-omission.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
2+
// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s -fexperimental-new-constant-interpreter
23

34
struct Noncopyable {
45
Noncopyable();

0 commit comments

Comments
 (0)