@@ -520,7 +520,7 @@ void CIRGenFunction::emitExprAsInit(const Expr *init, const ValueDecl *d,
520520 llvm_unreachable (" bad evaluation kind" );
521521}
522522
523- void CIRGenFunction::emitDecl (const Decl &d) {
523+ void CIRGenFunction::emitDecl (const Decl &d, bool evaluateConditionDecl ) {
524524 switch (d.getKind ()) {
525525 case Decl::BuiltinTemplate:
526526 case Decl::TranslationUnit:
@@ -614,10 +614,8 @@ void CIRGenFunction::emitDecl(const Decl &d) {
614614 assert (vd.isLocalVarDecl () &&
615615 " Should not see file-scope variables inside a function!" );
616616 emitVarDecl (vd);
617- if (auto *dd = dyn_cast<DecompositionDecl>(&vd))
618- for (BindingDecl *b : dd->bindings ())
619- if (VarDecl *hd = b->getHoldingVar ())
620- emitVarDecl (*hd);
617+ if (evaluateConditionDecl)
618+ maybeEmitDeferredVarDeclInit (&vd);
621619 return ;
622620 }
623621 case Decl::OpenACCDeclare:
@@ -801,3 +799,11 @@ void CIRGenFunction::emitAutoVarTypeCleanup(
801799 assert (!cir::MissingFeatures::ehCleanupFlags ());
802800 ehStack.pushCleanup <DestroyObject>(cleanupKind, addr, type, destroyer);
803801}
802+
803+ void CIRGenFunction::maybeEmitDeferredVarDeclInit (const VarDecl *vd) {
804+ if (auto *dd = dyn_cast_if_present<DecompositionDecl>(vd)) {
805+ for (auto *b : dd->flat_bindings ())
806+ if (auto *hd = b->getHoldingVar ())
807+ emitVarDecl (*hd);
808+ }
809+ }
0 commit comments