File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -4574,22 +4574,23 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
4574
4574
template <class Emitter >
4575
4575
bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
4576
4576
bool ConstantContext) {
4577
- std::optional<PrimType> VarT = classify (VD->getType ());
4578
4577
4579
4578
// We only create variables if we're evaluating in a constant context.
4580
4579
// Otherwise, just evaluate the initializer and return it.
4581
4580
if (!ConstantContext) {
4582
4581
DeclScope<Emitter> LS (this , VD);
4583
- if (!this ->visit (VD->getAnyInitializer ()))
4582
+ const Expr *Init = VD->getInit ();
4583
+ if (!this ->visit (Init))
4584
4584
return false ;
4585
- return this ->emitRet (VarT .value_or (PT_Ptr), VD) && LS. destroyLocals ( ) &&
4586
- this ->emitCheckAllocations (VD);
4585
+ return this ->emitRet (classify (Init) .value_or (PT_Ptr), VD) &&
4586
+ LS. destroyLocals () && this ->emitCheckAllocations (VD);
4587
4587
}
4588
4588
4589
4589
LocalScope<Emitter> VDScope (this , VD);
4590
4590
if (!this ->visitVarDecl (VD, /* Toplevel=*/ true ))
4591
4591
return false ;
4592
4592
4593
+ std::optional<PrimType> VarT = classify (VD->getType ());
4593
4594
if (Context::shouldBeGloballyIndexed (VD)) {
4594
4595
auto GlobalIndex = P.getGlobal (VD);
4595
4596
assert (GlobalIndex); // visitVarDecl() didn't return false.
You can’t perform that action at this time.
0 commit comments