| ... | @@ -21,7 +21,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -21,7 +21,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 21 | \\pub extern fn foo() -> noreturn; | 21 | \\pub extern fn foo() -> noreturn; |
| 22 | ); | 22 | ); |
| 23 | | 23 | |
| 24 | cases.add("simple function", | 24 | cases.addC("simple function", |
| 25 | \\int abs(int a) { | 25 | \\int abs(int a) { |
| 26 | \\ return a < 0 ? -a : a; | 26 | \\ return a < 0 ? -a : a; |
| 27 | \\} | 27 | \\} |
| ... | @@ -315,7 +315,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -315,7 +315,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 315 | \\pub const LUA_GLOBALSINDEX = -10002; | 315 | \\pub const LUA_GLOBALSINDEX = -10002; |
| 316 | ); | 316 | ); |
| 317 | | 317 | |
| 318 | cases.add("post increment", | 318 | cases.addC("post increment", |
| 319 | \\unsigned foo1(unsigned a) { | 319 | \\unsigned foo1(unsigned a) { |
| 320 | \\ a++; | 320 | \\ a++; |
| 321 | \\ return a; | 321 | \\ return a; |
| ... | @@ -337,7 +337,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -337,7 +337,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 337 | \\} | 337 | \\} |
| 338 | ); | 338 | ); |
| 339 | | 339 | |
| 340 | cases.add("shift right assign", | 340 | cases.addC("shift right assign", |
| 341 | \\int log2(unsigned a) { | 341 | \\int log2(unsigned a) { |
| 342 | \\ int i = 0; | 342 | \\ int i = 0; |
| 343 | \\ while (a > 0) { | 343 | \\ while (a > 0) { |
| ... | @@ -356,7 +356,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -356,7 +356,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 356 | \\} | 356 | \\} |
| 357 | ); | 357 | ); |
| 358 | | 358 | |
| 359 | cases.add("if statement", | 359 | cases.addC("if statement", |
| 360 | \\int max(int a, int b) { | 360 | \\int max(int a, int b) { |
| 361 | \\ if (a < b) | 361 | \\ if (a < b) |
| 362 | \\ return b; | 362 | \\ return b; |
| ... | @@ -373,7 +373,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -373,7 +373,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 373 | \\} | 373 | \\} |
| 374 | ); | 374 | ); |
| 375 | | 375 | |
| 376 | cases.add("==, !=", | 376 | cases.addC("==, !=", |
| 377 | \\int max(int a, int b) { | 377 | \\int max(int a, int b) { |
| 378 | \\ if (a == b) | 378 | \\ if (a == b) |
| 379 | \\ return a; | 379 | \\ return a; |
| ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 389 | \\} | 389 | \\} |
| 390 | ); | 390 | ); |
| 391 | | 391 | |
| 392 | cases.add("add, sub, mul, div, rem", | 392 | cases.addC("add, sub, mul, div, rem", |
| 393 | \\int s(int a, int b) { | 393 | \\int s(int a, int b) { |
| 394 | \\ int c; | 394 | \\ int c; |
| 395 | \\ c = a + b; | 395 | \\ c = a + b; |
| ... | @@ -425,7 +425,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -425,7 +425,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 425 | \\} | 425 | \\} |
| 426 | ); | 426 | ); |
| 427 | | 427 | |
| 428 | cases.add("bitwise binary operators", | 428 | cases.addC("bitwise binary operators", |
| 429 | \\int max(int a, int b) { | 429 | \\int max(int a, int b) { |
| 430 | \\ return (a & b) ^ (a | b); | 430 | \\ return (a & b) ^ (a | b); |
| 431 | \\} | 431 | \\} |
| ... | @@ -435,7 +435,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -435,7 +435,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 435 | \\} | 435 | \\} |
| 436 | ); | 436 | ); |
| 437 | | 437 | |
| 438 | cases.add("logical and, logical or", | 438 | cases.addC("logical and, logical or", |
| 439 | \\int max(int a, int b) { | 439 | \\int max(int a, int b) { |
| 440 | \\ if (a < b || a == b) | 440 | \\ if (a < b || a == b) |
| 441 | \\ return b; | 441 | \\ return b; |
| ... | @@ -451,7 +451,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -451,7 +451,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 451 | \\} | 451 | \\} |
| 452 | ); | 452 | ); |
| 453 | | 453 | |
| 454 | cases.add("assign", | 454 | cases.addC("assign", |
| 455 | \\int max(int a) { | 455 | \\int max(int a) { |
| 456 | \\ int tmp; | 456 | \\ int tmp; |
| 457 | \\ tmp = a; | 457 | \\ tmp = a; |
| ... | @@ -466,7 +466,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -466,7 +466,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 466 | \\} | 466 | \\} |
| 467 | ); | 467 | ); |
| 468 | | 468 | |
| 469 | cases.add("chaining assign", | 469 | cases.addC("chaining assign", |
| 470 | \\void max(int a) { | 470 | \\void max(int a) { |
| 471 | \\ int b, c; | 471 | \\ int b, c; |
| 472 | \\ c = b = a; | 472 | \\ c = b = a; |
| ... | @@ -483,7 +483,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -483,7 +483,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 483 | \\} | 483 | \\} |
| 484 | ); | 484 | ); |
| 485 | | 485 | |
| 486 | cases.add("shift right assign with a fixed size type", | 486 | cases.addC("shift right assign with a fixed size type", |
| 487 | \\#include <stdint.h> | 487 | \\#include <stdint.h> |
| 488 | \\int log2(uint32_t a) { | 488 | \\int log2(uint32_t a) { |
| 489 | \\ int i = 0; | 489 | \\ int i = 0; |
| ... | @@ -513,7 +513,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -513,7 +513,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 513 | \\pub const Two = 1; | 513 | \\pub const Two = 1; |
| 514 | ); | 514 | ); |
| 515 | | 515 | |
| 516 | cases.add("function call", | 516 | cases.addC("function call", |
| 517 | \\static void bar(void) { } | 517 | \\static void bar(void) { } |
| 518 | \\void foo(void) { bar(); } | 518 | \\void foo(void) { bar(); } |
| 519 | , | 519 | , |
| ... | @@ -523,7 +523,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -523,7 +523,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 523 | \\} | 523 | \\} |
| 524 | ); | 524 | ); |
| 525 | | 525 | |
| 526 | cases.add("field access expression", | 526 | cases.addC("field access expression", |
| 527 | \\struct Foo { | 527 | \\struct Foo { |
| 528 | \\ int field; | 528 | \\ int field; |
| 529 | \\}; | 529 | \\}; |
| ... | @@ -539,7 +539,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -539,7 +539,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 539 | \\} | 539 | \\} |
| 540 | ); | 540 | ); |
| 541 | | 541 | |
| 542 | cases.add("null statements", | 542 | cases.addC("null statements", |
| 543 | \\void foo(void) { | 543 | \\void foo(void) { |
| 544 | \\ ;;;;; | 544 | \\ ;;;;; |
| 545 | \\} | 545 | \\} |
| ... | @@ -553,7 +553,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -553,7 +553,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 553 | \\pub var array: [100]c_int = undefined; | 553 | \\pub var array: [100]c_int = undefined; |
| 554 | ); | 554 | ); |
| 555 | | 555 | |
| 556 | cases.add("array access", | 556 | cases.addC("array access", |
| 557 | \\int array[100]; | 557 | \\int array[100]; |
| 558 | \\int foo(int index) { | 558 | \\int foo(int index) { |
| 559 | \\ return array[index]; | 559 | \\ return array[index]; |
| ... | @@ -566,7 +566,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -566,7 +566,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 566 | ); | 566 | ); |
| 567 | | 567 | |
| 568 | | 568 | |
| 569 | cases.add("c style cast", | 569 | cases.addC("c style cast", |
| 570 | \\int float_to_int(float a) { | 570 | \\int float_to_int(float a) { |
| 571 | \\ return (int)a; | 571 | \\ return (int)a; |
| 572 | \\} | 572 | \\} |
| ... | @@ -576,7 +576,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -576,7 +576,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 576 | \\} | 576 | \\} |
| 577 | ); | 577 | ); |
| 578 | | 578 | |
| 579 | cases.add("implicit cast to void *", | 579 | cases.addC("implicit cast to void *", |
| 580 | \\void *foo(unsigned short *x) { | 580 | \\void *foo(unsigned short *x) { |
| 581 | \\ return x; | 581 | \\ return x; |
| 582 | \\} | 582 | \\} |
| ... | @@ -586,7 +586,7 @@ pub fn addCases(cases: &tests.ParseCContext) { | ... | @@ -586,7 +586,7 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 586 | \\} | 586 | \\} |
| 587 | ); | 587 | ); |
| 588 | | 588 | |
| 589 | cases.add("sizeof", | 589 | cases.addC("sizeof", |
| 590 | \\#include <stddef.h> | 590 | \\#include <stddef.h> |
| 591 | \\size_t size_of(void) { | 591 | \\size_t size_of(void) { |
| 592 | \\ return sizeof(int); | 592 | \\ return sizeof(int); |