diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 60b1e089e74a62..b8e32452371a46 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1107,23 +1107,6 @@ bool ByteCodeExprGen::visitInitList(ArrayRef Inits, return this->delegate(Inits[0]); } - // Prepare composite return value. - if (!Initializing) { - if (GlobalDecl) { - std::optional GlobalIndex = P.createGlobal(E); - if (!GlobalIndex) - return false; - if (!this->emitGetPtrGlobal(*GlobalIndex, E)) - return false; - } else { - std::optional LocalIndex = allocateLocal(E); - if (!LocalIndex) - return false; - if (!this->emitGetPtrGlobal(*LocalIndex, E)) - return false; - } - } - QualType T = E->getType(); if (T->isRecordType()) { const Record *R = getRecord(E->getType()); @@ -1224,6 +1207,23 @@ bool ByteCodeExprGen::visitInitList(ArrayRef Inits, } if (T->isArrayType()) { + // Prepare composite return value. + if (!Initializing) { + if (GlobalDecl) { + std::optional GlobalIndex = P.createGlobal(E); + if (!GlobalIndex) + return false; + if (!this->emitGetPtrGlobal(*GlobalIndex, E)) + return false; + } else { + std::optional LocalIndex = allocateLocal(E); + if (!LocalIndex) + return false; + if (!this->emitGetPtrLocal(*LocalIndex, E)) + return false; + } + } + unsigned ElementIndex = 0; for (const Expr *Init : Inits) { if (!this->visitArrayElemInit(ElementIndex, Init)) diff --git a/clang/test/SemaCXX/cxx0x-initializer-references.cpp b/clang/test/SemaCXX/cxx0x-initializer-references.cpp index 0f816a39f2ba09..f0018966e7e717 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-references.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-references.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter struct one { char c; }; struct two { char c[2]; };