| ... | @@ -355,6 +355,48 @@ done: | ... | @@ -355,6 +355,48 @@ done: |
| 355 | exit(0); | 355 | exit(0); |
| 356 | } | 356 | } |
| 357 | )SOURCE", "zero\nloop\nloop\nloop\n"); | 357 | )SOURCE", "zero\nloop\nloop\nloop\n"); |
| | 358 | |
| | 359 | add_simple_case("arrays", R"SOURCE( |
| | 360 | #link("c") |
| | 361 | extern { |
| | 362 | fn puts(s: *const u8) -> i32; |
| | 363 | fn exit(code: i32) -> unreachable; |
| | 364 | } |
| | 365 | |
| | 366 | export fn _start() -> unreachable { |
| | 367 | let mut array : [i32; 5]; |
| | 368 | |
| | 369 | let mut i = 0; |
| | 370 | loop_start: |
| | 371 | if i == 5 { |
| | 372 | goto loop_end; |
| | 373 | } |
| | 374 | array[i] = i + 1; |
| | 375 | i = array[i]; |
| | 376 | goto loop_start; |
| | 377 | |
| | 378 | loop_end: |
| | 379 | |
| | 380 | i = 0; |
| | 381 | let mut accumulator = 0; |
| | 382 | loop_2_start: |
| | 383 | if i == 5 { |
| | 384 | goto loop_2_end; |
| | 385 | } |
| | 386 | |
| | 387 | accumulator = accumulator + array[i]; |
| | 388 | |
| | 389 | i = i + 1; |
| | 390 | goto loop_2_start; |
| | 391 | loop_2_end: |
| | 392 | |
| | 393 | if accumulator == 15 { |
| | 394 | puts("OK"); |
| | 395 | } |
| | 396 | |
| | 397 | exit(0); |
| | 398 | } |
| | 399 | )SOURCE", "OK\n"); |
| 358 | } | 400 | } |
| 359 | | 401 | |
| 360 | static void add_compile_failure_test_cases(void) { | 402 | static void add_compile_failure_test_cases(void) { |