authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-27 01:19:55+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-27 14:14:17+03:00
logcd5b7b9e1d56b22bc2267d5d94acec8d21c29110
tree0f91f3a36bbccc482b2e004ccd08132ed82955df
parentb6e1670d2ba1e7724878ee2b7176077da5cb7c35
signature Commit is signed but in an unrecognized format.

translate-c: use correct scope in for loop condition


2 files changed, 14 insertions(+), 1 deletions(-)

src-self-hosted/translate_c.zig+1-1
......@@ -2515,7 +2515,7 @@ fn transForLoop(
25152515 }
25162516 var cond_scope = Scope.Condition{
25172517 .base = .{
2518 .parent = scope,
2518 .parent = &loop_scope,
25192519 .id = .Condition,
25202520 },
25212521 };
test/run_translated_c.zig+13
......@@ -256,4 +256,17 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
256256 \\ return 0;
257257 \\}
258258 , "");
259
260 cases.add("scoped for loops with shadowing",
261 \\#include <stdlib.h>
262 \\int main() {
263 \\ int count = 0;
264 \\ for (int x = 0; x < 2; x++)
265 \\ for (int x = 0; x < 2; x++)
266 \\ count++;
267 \\
268 \\ if (count != 4) abort();
269 \\ return 0;
270 \\}
271 ,"");
259272}