@@ -423,6 +423,11 @@ bool ByteCodeStmtGen<Emitter>::visitWhileStmt(const WhileStmt *S) {
423
423
LoopScope<Emitter> LS (this , EndLabel, CondLabel);
424
424
425
425
this ->emitLabel (CondLabel);
426
+
427
+ if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
428
+ if (!visitDeclStmt (CondDecl))
429
+ return false ;
430
+
426
431
if (!this ->visitBool (Cond))
427
432
return false ;
428
433
if (!this ->jumpFalse (EndLabel))
@@ -487,6 +492,10 @@ bool ByteCodeStmtGen<Emitter>::visitForStmt(const ForStmt *S) {
487
492
if (Init && !this ->visitStmt (Init))
488
493
return false ;
489
494
this ->emitLabel (CondLabel);
495
+
496
+ if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
497
+ if (!visitDeclStmt (CondDecl))
498
+ return false ;
490
499
if (Cond) {
491
500
if (!this ->visitBool (Cond))
492
501
return false ;
@@ -585,17 +594,21 @@ bool ByteCodeStmtGen<Emitter>::visitContinueStmt(const ContinueStmt *S) {
585
594
template <class Emitter >
586
595
bool ByteCodeStmtGen<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
587
596
const Expr *Cond = S->getCond ();
588
- PrimType CondT = this ->classifyPrim (Cond->getType ());
589
597
590
598
LabelTy EndLabel = this ->getLabel ();
591
599
OptLabelTy DefaultLabel = std::nullopt;
592
- unsigned CondVar = this ->allocateLocalPrimitive (Cond, CondT, true , false );
593
600
594
601
if (const auto *CondInit = S->getInit ())
595
602
if (!visitStmt (CondInit))
596
603
return false ;
597
604
605
+ if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
606
+ if (!visitDeclStmt (CondDecl))
607
+ return false ;
608
+
598
609
// Initialize condition variable.
610
+ PrimType CondT = this ->classifyPrim (Cond->getType ());
611
+ unsigned CondVar = this ->allocateLocalPrimitive (Cond, CondT, true , false );
599
612
if (!this ->visit (Cond))
600
613
return false ;
601
614
if (!this ->emitSetLocal (CondT, CondVar, S))
0 commit comments