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,
45744574template <class Emitter >
45754575bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
45764576 bool ConstantContext) {
4577- std::optional<PrimType> VarT = classify (VD->getType ());
45784577
45794578 // We only create variables if we're evaluating in a constant context.
45804579 // Otherwise, just evaluate the initializer and return it.
45814580 if (!ConstantContext) {
45824581 DeclScope<Emitter> LS (this , VD);
4583- if (!this ->visit (VD->getAnyInitializer ()))
4582+ const Expr *Init = VD->getInit ();
4583+ if (!this ->visit (Init))
45844584 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);
45874587 }
45884588
45894589 LocalScope<Emitter> VDScope (this , VD);
45904590 if (!this ->visitVarDecl (VD, /* Toplevel=*/ true ))
45914591 return false ;
45924592
4593+ std::optional<PrimType> VarT = classify (VD->getType ());
45934594 if (Context::shouldBeGloballyIndexed (VD)) {
45944595 auto GlobalIndex = P.getGlobal (VD);
45954596 assert (GlobalIndex); // visitVarDecl() didn't return false.
You can’t perform that action at this time.
0 commit comments