Unified · Split
| @@ -33,7 +33,7 @@ void char_short_test(); · 32 unmodified lines | |||
| 33 | void init_test(void); | 33 | void init_test(void); |
| 34 | void compound_literal_test(void); | 34 | void compound_literal_test(void); |
| 35 | int kr_test(); | 35 | int kr_test(); |
| 36 | void struct_assign_test(); | 36 | void struct_assign_test(void); |
| 37 | void cast_test(void); | 37 | void cast_test(void); |
| 38 | void bitfield_test(void); | 38 | void bitfield_test(void); |
| 39 | void c99_bool_test(void); | 39 | void c99_bool_test(void); |
| @@ -62,6 +62,11 @@ int isid(int c); · 22 unmodified lines | |||
| 62 | #define dprintf(level,...) printf(__VA_ARGS__) | 62 | #define dprintf(level,...) printf(__VA_ARGS__) |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | /* gcc vararg macros */ | ||
| 66 | #define dprintf1(level, fmt, args...) printf(fmt, ## args) | ||
| 67 | |||
| 68 | #define MACRO_NOARGS() | ||
| 69 | |||
| 65 | #define AAA 3 | 70 | #define AAA 3 |
| 66 | #undef AAA | 71 | #undef AAA |
| 67 | #define AAA 4 | 72 | #define AAA 4 |
| @@ -149,6 +154,8 @@ void macro_test() · 81 unmodified lines | |||
| 149 | printf("test 3\n"); | 154 | printf("test 3\n"); |
| 150 | #endif | 155 | #endif |
| 151 | 156 | ||
| 157 | MACRO_NOARGS(); | ||
| 158 | |||
| 152 | printf("__LINE__=%d __FILE__=%s\n", | 159 | printf("__LINE__=%d __FILE__=%s\n", |
| 153 | __LINE__, __FILE__); | 160 | __LINE__, __FILE__); |
| 154 | /* not strictly preprocessor, but we test it there */ | 161 | /* not strictly preprocessor, but we test it there */ |
| @@ -156,6 +163,9 @@ void macro_test() · 1 unmodified line | |||
| 156 | printf("__func__ = %s\n", __func__); | 163 | printf("__func__ = %s\n", __func__); |
| 157 | dprintf(1, "vaarg=%d\n", 1); | 164 | dprintf(1, "vaarg=%d\n", 1); |
| 158 | #endif | 165 | #endif |
| 166 | dprintf1(1, "vaarg1\n"); | ||
| 167 | dprintf1(1, "vaarg1=%d\n", 2); | ||
| 168 | dprintf1(1, "vaarg1=%d %d\n", 1, 2); | ||
| 159 | } | 169 | } |
| 160 | 170 | ||
| 161 | int op(a,b) | 171 | int op(a,b) |
| @@ -648,7 +658,7 @@ typedef struct Sym { · 486 unmodified lines | |||
| 648 | 658 | ||
| 649 | void bool_test() | 659 | void bool_test() |
| 650 | { | 660 | { |
| 651 | int *s, a; | 661 | int *s, a, b; |
| 652 | 662 | ||
| 653 | a = 0; | 663 | a = 0; |
| 654 | s = (void*)0; | 664 | s = (void*)0; |
| @@ -676,6 +686,13 @@ void bool_test() · 21 unmodified lines | |||
| 676 | 686 | ||
| 677 | a = 4; | 687 | a = 4; |
| 678 | printf("b=%d\n", a + (0 ? 1 : a / 2)); | 688 | printf("b=%d\n", a + (0 ? 1 : a / 2)); |
| 689 | |||
| 690 | /* test register spilling */ | ||
| 691 | a = 10; | ||
| 692 | b = 10; | ||
| 693 | a = (a + b) * ((a < b) ? | ||
| 694 | ((b - a) * (a - b)): a + b); | ||
| 695 | printf("a=%d\n", a); | ||
| 679 | } | 696 | } |
| 680 | 697 | ||
| 681 | 698 | ||
| @@ -785,10 +802,11 @@ struct structa1 struct_assign_test2(struct structa1 s1, int t) · 103 unmodified lines | |||
| 785 | return s1; | 802 | return s1; |
| 786 | } | 803 | } |
| 787 | 804 | ||
| 788 | void struct_assign_test() | 805 | void struct_assign_test(void) |
| 789 | { | 806 | { |
| 790 | struct structa1 lsta1, lsta2; | 807 | struct structa1 lsta1, lsta2; |
| 791 | 808 | ||
| 809 | #if 0 | ||
| 792 | printf("struct_assign_test:\n"); | 810 | printf("struct_assign_test:\n"); |
| 793 | 811 | ||
| 794 | lsta1.f1 = 1; | 812 | lsta1.f1 = 1; |
| @@ -796,7 +814,10 @@ void struct_assign_test() · 1 unmodified line | |||
| 796 | printf("%d %d\n", lsta1.f1, lsta1.f2); | 814 | printf("%d %d\n", lsta1.f1, lsta1.f2); |
| 797 | lsta2 = lsta1; | 815 | lsta2 = lsta1; |
| 798 | printf("%d %d\n", lsta2.f1, lsta2.f2); | 816 | printf("%d %d\n", lsta2.f1, lsta2.f2); |
| 799 | 817 | #else | |
| 818 | lsta2.f1 = 1; | ||
| 819 | lsta2.f2 = 2; | ||
| 820 | #endif | ||
| 800 | struct_assign_test1(lsta2, 3); | 821 | struct_assign_test1(lsta2, 3); |
| 801 | 822 | ||
| 802 | printf("before call: %d %d\n", lsta2.f1, lsta2.f2); | 823 | printf("before call: %d %d\n", lsta2.f1, lsta2.f2); |
| @@ -817,6 +838,8 @@ short scast; · 14 unmodified lines | |||
| 817 | void cast_test() | 838 | void cast_test() |
| 818 | { | 839 | { |
| 819 | int a; | 840 | int a; |
| 841 | char c; | ||
| 842 | char tab[10]; | ||
| 820 | 843 | ||
| 821 | printf("cast_test:\n"); | 844 | printf("cast_test:\n"); |
| 822 | a = 0xfffff; | 845 | a = 0xfffff; |
| @@ -837,6 +860,14 @@ void cast_test() · 14 unmodified lines | |||
| 837 | printf("%d\n", a); | 860 | printf("%d\n", a); |
| 838 | a = (scast = 65536) + 1; | 861 | a = (scast = 65536) + 1; |
| 839 | printf("%d\n", a); | 862 | printf("%d\n", a); |
| 863 | |||
| 864 | printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c)); | ||
| 865 | |||
| 866 | /* test implicit int casting for array accesses */ | ||
| 867 | c = 0; | ||
| 868 | tab[1] = 2; | ||
| 869 | tab[c] = 1; | ||
| 870 | printf("%d %d\n", tab[0], tab[1]); | ||
| 840 | } | 871 | } |
| 841 | 872 | ||
| 842 | /* initializers tests */ | 873 | /* initializers tests */ |
| @@ -873,6 +904,7 @@ char *sinit13[] = { · 30 unmodified lines | |||
| 873 | "test3", | 904 | "test3", |
| 874 | }; | 905 | }; |
| 875 | char sinit14[10] = { "abc" }; | 906 | char sinit14[10] = { "abc" }; |
| 907 | int sinit15[3] = { sizeof(sinit15), 1, 2 }; | ||
| 876 | 908 | ||
| 877 | void init_test(void) | 909 | void init_test(void) |
| 878 | { | 910 | { |
| @@ -887,6 +919,7 @@ void init_test(void) · 8 unmodified lines | |||
| 887 | char linit14[10] = "abc"; | 919 | char linit14[10] = "abc"; |
| 888 | int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, }; | 920 | int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, }; |
| 889 | struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 }; | 921 | struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 }; |
| 922 | int linit17 = sizeof(linit17); | ||
| 890 | 923 | ||
| 891 | printf("init_test:\n"); | 924 | printf("init_test:\n"); |
| 892 | 925 | ||
| @@ -955,6 +988,9 @@ void init_test(void) · 62 unmodified lines | |||
| 955 | linit16.a2, | 988 | linit16.a2, |
| 956 | linit16.a3, | 989 | linit16.a3, |
| 957 | linit16.a4); | 990 | linit16.a4); |
| 991 | /* test that initialisation is done after variable declare */ | ||
| 992 | printf("linit17=%d\n", linit17); | ||
| 993 | printf("sinit15=%d\n", sinit15[0]); | ||
| 958 | } | 994 | } |
| 959 | 995 | ||
| 960 | void switch_test() | 996 | void switch_test() |