Skip to content

Commit 08b361e

Browse files
tbaederrLukacma
authored andcommitted
[clang][bytecode] Fix initializing primitive fields via initlist (llvm#164789)
Fixes llvm#152901
1 parent 05f20fe commit 08b361e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,6 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
18421842
const Expr *Init, PrimType T,
18431843
bool Activate = false) -> bool {
18441844
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(Init));
1845-
InitLinkScope<Emitter> ILS(this, InitLink::Field(FieldToInit->Offset));
18461845
if (!this->visit(Init))
18471846
return false;
18481847

clang/test/AST/ByteCode/records.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,3 +1840,11 @@ namespace DiamondDowncast {
18401840
constexpr Middle2 &fail = (Middle2&)top1; // both-error {{must be initialized by a constant expression}} \
18411841
// both-note {{cannot cast object of dynamic type 'const Bottom' to type 'Middle2'}}
18421842
}
1843+
1844+
namespace PrimitiveInitializedByInitList {
1845+
constexpr struct {
1846+
int a;
1847+
int b{this->a};
1848+
} c{ 17 };
1849+
static_assert(c.b == 17, "");
1850+
}

0 commit comments

Comments
 (0)