diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index b95126ee20fe2..59fddfc2da195 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -863,6 +863,10 @@ bool ByteCodeExprGen::visitInitList(ArrayRef Inits, assert(E->getType()->isRecordType()); const Record *R = getRecord(E->getType()); + if (Inits.size() == 1 && E->getType() == Inits[0]->getType()) { + return this->visitInitializer(Inits[0]); + } + unsigned InitIndex = 0; for (const Expr *Init : Inits) { if (!this->emitDupPtr(E)) diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index c6aac7938a297..5ce1e6e09a0b7 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -7,6 +7,10 @@ // RUN: %clang_cc1 -verify=ref -std=c++20 %s // RUN: %clang_cc1 -verify=ref -triple i686 %s +/// Used to crash. +struct Empty {}; +constexpr Empty e = {Empty()}; + struct BoolPair { bool first; bool second; diff --git a/clang/test/SemaCXX/cxx1z-copy-omission.cpp b/clang/test/SemaCXX/cxx1z-copy-omission.cpp index f46a17af83386..92ebfdd8e4c73 100644 --- a/clang/test/SemaCXX/cxx1z-copy-omission.cpp +++ b/clang/test/SemaCXX/cxx1z-copy-omission.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s +// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s -fexperimental-new-constant-interpreter struct Noncopyable { Noncopyable();