| author | |
| committer | |
| log | 2ae9e06363b294f60b62e765d31fce4417e14a9d |
| tree | 2490713f0d933708c4e7b7fd0eaa48af141cba39 |
| parent | e61e8c94beba912400b71891d8bfcfa9c1c1d837 |
| parent | cd5b7b9e1d56b22bc2267d5d94acec8d21c29110 |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
Translate-c use correct scope in for loop condition2 files changed, 14 insertions(+), 1 deletions(-)
src-self-hosted/translate_c.zig+1-1| ... | ... | @@ -2515,7 +2515,7 @@ fn transForLoop( |
| 2515 | 2515 | } |
| 2516 | 2516 | var cond_scope = Scope.Condition{ |
| 2517 | 2517 | .base = .{ |
| 2518 | .parent = scope, | |
| 2518 | .parent = &loop_scope, | |
| 2519 | 2519 | .id = .Condition, |
| 2520 | 2520 | }, |
| 2521 | 2521 | }; |
test/run_translated_c.zig+13| ... | ... | @@ -256,4 +256,17 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 256 | 256 | \\ return 0; |
| 257 | 257 | \\} |
| 258 | 258 | , ""); |
| 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 | ,""); | |
| 259 | 272 | } |