* case 1: local scope of 'ff' int main() { int ff = 123; { int ff(int): ff(456) }} * case 2: linkage of a static extern symbol (older gcc did allow that) static int ff(int); int main() { int ff(int): ff(456) } Also: - cleanup enum, let sym_push() handle redefinition - just mark incomplete array base types, unshare only when needed (in decl_initializer_alloc()) - fix sizeof empty array (= 0) : int ii[] = {}; - rename 'Sym' members used by __attribute__((cleanup(f)))
Showing the changes to tests (7 of 10 files). Show all
Unified · Split
| @@ -77,40 +77,101 @@ struct st func(void) · 76 unmodified lines | ||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /* --------------------------------------------- */ |
| 80 | −static void func2(char *(*md)(char *md)) | |
| 80 | +/* func* 'md' must not be shadowed by param 'md' */ | |
| 81 | +static void f4(char *(*md)(char *md)) | |
| 81 | 82 | { |
| 82 | 83 | (*md)("test"); |
| 83 | 84 | } |
| 84 | − | |
| 85 | −static char *a(char *a) | |
| 85 | +static char *a4(char *a) | |
| 86 | 86 | { |
| 87 | − printf("%s\n", a); | |
| 87 | + int strcmp(); | |
| 88 | + myassert(!strcmp(a, "test")); | |
| 88 | 89 | return a; |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | −int main_4(void) | |
| 92 | +int main_4() | |
| 92 | 93 | { |
| 93 | − func2(a); | |
| 94 | + f4(a4); | |
| 94 | 95 | return 0; |
| 95 | 96 | } |
| 96 | 97 | |
| 97 | 98 | /* --------------------------------------------- */ |
| 98 | −int b[3]; | |
| 99 | −int f(void); | |
| 99 | +int a5[3], b5[]; | |
| 100 | +int f5(void); | |
| 101 | +int main_5() | |
| 102 | +{ | |
| 103 | + extern int a5[3], b5[3]; | |
| 104 | + a5[2]=10, b5[2]=4; | |
| 105 | + myassert(f5() == 10 + 4); | |
| 106 | + return 0; | |
| 107 | +} | |
| 108 | +int f5(void) | |
| 109 | +{ | |
| 110 | + return a5[2]+b5[2]; | |
| 111 | +} | |
| 112 | +int b5[3]; | |
| 100 | 113 | |
| 101 | −int main_5(void) | |
| 114 | +/* --------------------------------------------- */ | |
| 115 | +static int f6(int); | |
| 116 | +int i6 = 11; | |
| 117 | + | |
| 118 | +int main_6() | |
| 102 | 119 | { |
| 103 | − extern int b[3]; | |
| 104 | − b[2]=10; | |
| 105 | − printf("%d\n", f()); | |
| 120 | + { | |
| 121 | + int i6 = 33, f6 = 44; | |
| 122 | + myassert(i6 == 33 && f6 == 44); | |
| 123 | + { | |
| 124 | + int f6(int); | |
| 125 | + extern int i6; | |
| 126 | + myassert(i6 == 11 && f6(22) == 22); | |
| 127 | + } | |
| 128 | + myassert(i6 == 33 && f6 == 44); | |
| 129 | + } | |
| 130 | + myassert(i6 == 11 && f6(22) == 22); | |
| 106 | 131 | return 0; |
| 107 | 132 | } |
| 108 | 133 | |
| 109 | −int f(void) | |
| 134 | +int f6(int x) | |
| 110 | 135 | { |
| 111 | − return b[2]==10 ? 1 : 0; | |
| 136 | + return x; | |
| 112 | 137 | } |
| 113 | 138 | |
| 139 | +/* --------------------------------------------- */ | |
| 140 | + | |
| 141 | +#if defined __TINYC__ \ | |
| 142 | + ? !defined __leading_underscore \ | |
| 143 | + : !(defined __APPLE__ || defined _WIN32) | |
| 144 | +# define _ | |
| 145 | +#else | |
| 146 | +# define _ "_" | |
| 147 | +#endif | |
| 148 | + | |
| 149 | +struct xx7 { int a, b; }; | |
| 150 | + | |
| 151 | +void f7() | |
| 152 | +{ | |
| 153 | + struct xx7 { int c; } x; | |
| 154 | + { | |
| 155 | + extern struct xx7 { int a, b; } x __asm__(_"z7"); | |
| 156 | + x.a = 12; | |
| 157 | + struct xx7 y = { 0,0 }; | |
| 158 | + } | |
| 159 | + struct xx7 y = { 90 }; | |
| 160 | + x.c = 78; | |
| 161 | + printf("xx7 (1) : %d %d\n", x.c, y.c); | |
| 162 | +} | |
| 163 | + | |
| 164 | +int main_7() | |
| 165 | +{ | |
| 166 | + f7(); | |
| 167 | + extern struct xx7 y __asm__(_"z7"); | |
| 168 | + printf("xx7 (2) : %d %d\n", y.a, y.b); | |
| 169 | + return 0; | |
| 170 | +} | |
| 171 | + | |
| 172 | + | |
| 173 | +struct xx7 z7 = { 0, 34 }; | |
| 174 | + | |
| 114 | 175 | /* --------------------------------------------- */ |
| 115 | 176 | int main() |
| 116 | 177 | { |
| @@ -119,5 +180,7 @@ int main() · 2 unmodified lines | ||
| 119 | 180 | main_3(); |
| 120 | 181 | main_4(); |
| 121 | 182 | main_5(); |
| 183 | + main_6(); | |
| 184 | + main_7(); | |
| 122 | 185 | return 0; |
| 123 | 186 | } |
| @@ -21,5 +21,11 @@ · 20 unmodified lines | ||
| 21 | 21 | 129_scopes.c:43: ok : "!in" |
| 22 | 22 | 129_scopes.c:59: ok : "c == 'a'" |
| 23 | 23 | 129_scopes.c:69: ok : "st.a == 10" |
| 24 | −test | |
| 25 | −1 | |
| 24 | +129_scopes.c:88: ok : "!strcmp(a, "test")" | |
| 25 | +129_scopes.c:105: ok : "f5() == 10 + 4" | |
| 26 | +129_scopes.c:122: ok : "i6 == 33 && f6 == 44" | |
| 27 | +129_scopes.c:126: ok : "i6 == 11 && f6(22) == 22" | |
| 28 | +129_scopes.c:128: ok : "i6 == 33 && f6 == 44" | |
| 29 | +129_scopes.c:130: ok : "i6 == 11 && f6(22) == 22" | |
| 30 | +xx7 (1) : 78 90 | |
| 31 | +xx7 (2) : 12 34 | |
| @@ -1,14 +1,30 @@ | ||
| 1 | −#include <stdio.h> | |
| 1 | +int printf(const char*, ...); | |
| 2 | 2 | |
| 3 | 3 | int main() |
| 4 | 4 | { |
| 5 | − char a; | |
| 6 | − short b; | |
| 5 | + char a; | |
| 6 | + short b; | |
| 7 | 7 | |
| 8 | − printf("%d %d\n", sizeof(char), sizeof(a)); | |
| 9 | − printf("%d %d\n", sizeof(short), sizeof(b)); | |
| 8 | + printf("sizeof a : %d %d\n", sizeof(char), sizeof(a)); | |
| 9 | + printf("sizeof b : %d %d\n", sizeof(short), sizeof(b)); | |
| 10 | 10 | |
| 11 | − return 0; | |
| 12 | −} | |
| 11 | + int ii[] = {}; /* gnu extension, size = 0 */ | |
| 12 | + printf("sizeof ii : %d\n", sizeof ii); | |
| 13 | + | |
| 14 | + int kk[] = { 1 }; | |
| 15 | + printf("sizeof kk : %d\n", sizeof kk); | |
| 16 | + | |
| 17 | + char cc[] = "12"; | |
| 18 | + printf("sizeof cc : %d\n", sizeof cc); | |
| 13 | 19 | |
| 14 | −/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ | |
| 20 | + __WCHAR_TYPE__ ll[] = L"12345"; | |
| 21 | + printf("len-of ll : %d\n", sizeof ll / sizeof ll[0]); | |
| 22 | + | |
| 23 | + static struct { | |
| 24 | + int a,b,c; | |
| 25 | + int d[]; | |
| 26 | + } ss[] = {{ 1, 2, 3, {} }}; | |
| 27 | + printf("sizeof ss : %d\n", sizeof ss); | |
| 28 | + | |
| 29 | + return 0; | |
| 30 | +} | |
| @@ -1,2 +1,7 @@ | ||
| 1 | −1 1 | |
| 2 | −2 2 | |
| 1 | +sizeof a : 1 1 | |
| 2 | +sizeof b : 2 2 | |
| 3 | +sizeof ii : 0 | |
| 4 | +sizeof kk : 4 | |
| 5 | +sizeof cc : 3 | |
| 6 | +len-of ll : 6 | |
| 7 | +sizeof ss : 12 | |
| @@ -13,6 +13,7 @@ typedef struct FunStruct MyFunStruct; · 12 unmodified lines | ||
| 13 | 13 | typedef MyFunStruct *MoreFunThanEver; |
| 14 | 14 | |
| 15 | 15 | typedef int t[]; |
| 16 | +int tints[]; | |
| 16 | 17 | |
| 17 | 18 | int main() |
| 18 | 19 | { |
| @@ -36,6 +37,14 @@ int main() · 17 unmodified lines | ||
| 36 | 37 | printf("%d\n", (int)sizeof((t){1,2,3})); |
| 37 | 38 | printf("%d\n", (int)sizeof((t){1,2,3,4})); |
| 38 | 39 | |
| 40 | + /* two arrays derived from same base type */ | |
| 41 | + t t3 = { 1,2,3 }, t4 = { 4,5,6,7 }; | |
| 42 | + for (p = t3, i = 0; i < 3 ; i++) printf("%d ", *p++); | |
| 43 | + for (p = t4, i = 0; i < 4 ; i++) printf("%d ", *p++); printf("\n"); | |
| 44 | + typeof(tints) t5 = { 1,2,3 }, t6 = { 4,5,6,7 }; | |
| 45 | + for (p = t5, i = 0; i < 3 ; i++) printf("%d ", *p++); | |
| 46 | + for (p = t6, i = 0; i < 4 ; i++) printf("%d ", *p++); printf("\n"); | |
| 47 | + | |
| 39 | 48 | return 0; |
| 40 | 49 | } |
| 41 | 50 | |
| @@ -5,3 +5,5 @@ · 4 unmodified lines | ||
| 5 | 5 | 1 2 3 4 |
| 6 | 6 | 12 |
| 7 | 7 | 16 |
| 8 | +1 2 3 4 5 6 7 | |
| 9 | +1 2 3 4 5 6 7 | |
| @@ -17,7 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | 60_errors_and_warnings.c:21: error: struct/union/enum already defined |
| 18 | 18 | |
| 19 | 19 | [test_62_enumerator_redefinition] |
| 20 | −60_errors_and_warnings.c:26: error: redefinition of enumerator 'RED' | |
| 20 | +60_errors_and_warnings.c:26: error: redeclaration of 'RED' | |
| 21 | 21 | |
| 22 | 22 | [test_63_local_enumerator_redefinition] |
| 23 | 23 | [returns 1] |