ID/Stmt: Introduce INIT_SKIP and use in ForStmt

Currently, loop vars are added to a function scope's inits and
initialized upon entering a function with default values. This
applies to vector, record and table types.

This is unnecessary for variables used in for loops as they are
guaranteed to be initialized while iterating.
This commit is contained in:
Arne Welzel 2023-09-01 19:14:54 +02:00
parent aaa81cae5d
commit cea7c0ab46
7 changed files with 287 additions and 288 deletions

View file

@ -420,7 +420,9 @@ StmtPtr add_local(IDPtr id, TypePtr t, InitClass c, ExprPtr init,
else
{
current_scope()->AddInit(std::move(id));
if ( c != INIT_SKIP )
current_scope()->AddInit(std::move(id));
return make_intrusive<NullStmt>();
}
}