Unified · Split
| @@ -60,6 +60,9 @@ void longlong_test(void); · 59 unmodified lines | |||
| 60 | void stdarg_test(void); | 60 | void stdarg_test(void); |
| 61 | void whitespace_test(void); | 61 | void whitespace_test(void); |
| 62 | void relocation_test(void); | 62 | void relocation_test(void); |
| 63 | void old_style_function(void); | ||
| 64 | void sizeof_test(void); | ||
| 65 | void typeof_test(void); | ||
| 63 | 66 | ||
| 64 | int fib(int n); | 67 | int fib(int n); |
| 65 | void num(int n); | 68 | void num(int n); |
| @@ -192,7 +195,7 @@ void macro_test(void) · 126 unmodified lines | |||
| 192 | #line 203 "test" | 195 | #line 203 "test" |
| 193 | printf("__LINE__=%d __FILE__=%s\n", | 196 | printf("__LINE__=%d __FILE__=%s\n", |
| 194 | __LINE__, __FILE__); | 197 | __LINE__, __FILE__); |
| 195 | #line 195 "tcctest.c" | 198 | #line 198 "tcctest.c" |
| 196 | 199 | ||
| 197 | /* not strictly preprocessor, but we test it there */ | 200 | /* not strictly preprocessor, but we test it there */ |
| 198 | #ifdef C99_MACROS | 201 | #ifdef C99_MACROS |
| @@ -208,6 +211,14 @@ void macro_test(void) · 9 unmodified lines | |||
| 208 | 211 | ||
| 209 | /* complicated macros in glibc */ | 212 | /* complicated macros in glibc */ |
| 210 | printf("INT64_MIN=%Ld\n", INT64_MIN); | 213 | printf("INT64_MIN=%Ld\n", INT64_MIN); |
| 214 | { | ||
| 215 | int a; | ||
| 216 | a = 1; | ||
| 217 | glue(a+, +); | ||
| 218 | printf("a=%d\n", a); | ||
| 219 | glue(a <, <= 2); | ||
| 220 | printf("a=%d\n", a); | ||
| 221 | } | ||
| 211 | } | 222 | } |
| 212 | 223 | ||
| 213 | int op(a,b) | 224 | int op(a,b) |
| @@ -428,6 +439,9 @@ int main(int argc, char **argv) · 214 unmodified lines | |||
| 428 | stdarg_test(); | 439 | stdarg_test(); |
| 429 | whitespace_test(); | 440 | whitespace_test(); |
| 430 | relocation_test(); | 441 | relocation_test(); |
| 442 | old_style_function(); | ||
| 443 | sizeof_test(); | ||
| 444 | typeof_test(); | ||
| 431 | return 0; | 445 | return 0; |
| 432 | } | 446 | } |
| 433 | 447 | ||
| @@ -466,12 +480,6 @@ void array_test(int a[4]) · 32 unmodified lines | |||
| 466 | 480 | ||
| 467 | printf("array:\n"); | 481 | printf("array:\n"); |
| 468 | printf("sizeof(a) = %d\n", sizeof(a)); | 482 | printf("sizeof(a) = %d\n", sizeof(a)); |
| 469 | printf("sizeof(int) = %d\n", sizeof(int)); | ||
| 470 | printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int)); | ||
| 471 | printf("sizeof(short) = %d\n", sizeof(short)); | ||
| 472 | printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short)); | ||
| 473 | printf("sizeof(char) = %d\n", sizeof(char)); | ||
| 474 | printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char)); | ||
| 475 | printf("sizeof(\"a\") = %d\n", sizeof("a")); | 483 | printf("sizeof(\"a\") = %d\n", sizeof("a")); |
| 476 | #ifdef C99_MACROS | 484 | #ifdef C99_MACROS |
| 477 | printf("sizeof(__func__) = %d\n", sizeof(__func__)); | 485 | printf("sizeof(__func__) = %d\n", sizeof(__func__)); |
| @@ -1502,3 +1510,55 @@ void relocation_test(void) · 1024 unmodified lines | |||
| 1502 | printf("*rel1=%d\n", *rel1); | 1510 | printf("*rel1=%d\n", *rel1); |
| 1503 | printf("*rel2=%d\n", *rel2); | 1511 | printf("*rel2=%d\n", *rel2); |
| 1504 | } | 1512 | } |
| 1513 | |||
| 1514 | void old_style_f(a,b,c) | ||
| 1515 | int a, b; | ||
| 1516 | double c; | ||
| 1517 | { | ||
| 1518 | printf("a=%d b=%d b=%f\n", a, b, c); | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | void old_style_function(void) | ||
| 1522 | { | ||
| 1523 | old_style_f((void *)1, 2, 3.0); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | void sizeof_test(void) | ||
| 1527 | { | ||
| 1528 | int a; | ||
| 1529 | int **ptr; | ||
| 1530 | |||
| 1531 | printf("sizeof(int) = %d\n", sizeof(int)); | ||
| 1532 | printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int)); | ||
| 1533 | printf("sizeof(short) = %d\n", sizeof(short)); | ||
| 1534 | printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short)); | ||
| 1535 | printf("sizeof(char) = %d\n", sizeof(char)); | ||
| 1536 | printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char)); | ||
| 1537 | printf("sizeof(func) = %d\n", sizeof sizeof_test()); | ||
| 1538 | a = 1; | ||
| 1539 | printf("sizeof(a++) = %d\n", sizeof a++); | ||
| 1540 | printf("a=%d\n", a); | ||
| 1541 | ptr = NULL; | ||
| 1542 | printf("sizeof(**ptr) = %d\n", sizeof (**ptr)); | ||
| 1543 | |||
| 1544 | /* some alignof tests */ | ||
| 1545 | printf("__alignof__(int) = %d\n", __alignof__(int)); | ||
| 1546 | printf("__alignof__(unsigned int) = %d\n", __alignof__(unsigned int)); | ||
| 1547 | printf("__alignof__(short) = %d\n", __alignof__(short)); | ||
| 1548 | printf("__alignof__(unsigned short) = %d\n", __alignof__(unsigned short)); | ||
| 1549 | printf("__alignof__(char) = %d\n", __alignof__(char)); | ||
| 1550 | printf("__alignof__(unsigned char) = %d\n", __alignof__(unsigned char)); | ||
| 1551 | printf("__alignof__(func) = %d\n", __alignof__ sizeof_test()); | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | void typeof_test(void) | ||
| 1555 | { | ||
| 1556 | double a; | ||
| 1557 | typeof(a) b; | ||
| 1558 | typeof(float) c; | ||
| 1559 | |||
| 1560 | a = 1.5; | ||
| 1561 | b = 2.5; | ||
| 1562 | c = 3.5; | ||
| 1563 | printf("a=%f b=%f c=%f\n", a, b, c); | ||
| 1564 | } | ||