authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-27 17:00:31+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-05-27 17:00:31+03:00
log2ae9e06363b294f60b62e765d31fce4417e14a9d
tree2490713f0d933708c4e7b7fd0eaa48af141cba39
parente61e8c94beba912400b71891d8bfcfa9c1c1d837
parentcd5b7b9e1d56b22bc2267d5d94acec8d21c29110
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5448 from Vexu/translate-c

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}