History

Fix static assert with empty string

herman ten brugge committed 3 years ago

Commit 065b4011 parent a722a123 files · +38 −32Browse files

Unified · Split

3 files
  1. tccpp.c +1 −1
  2. tests/tests2/60_errors_and_warnings.c +3 −0
  3. tests/tests2/60_errors_and_warnings.expect +34 −31
tccpp.c+1−1
@@ -420,7 +420,7 @@ ST_FUNC int cstr_vprintf(CString *cstr, const char *fmt, va_list ap) · 419 unmodified lines
420 va_copy(v, ap);420 va_copy(v, ap);
421 len = vsnprintf((char*)cstr->data + cstr->size, size, fmt, v);421 len = vsnprintf((char*)cstr->data + cstr->size, size, fmt, v);
422 va_end(v);422 va_end(v);
423 if (len > 0 && len < size)423 if (len >= 0 && len < size)
424 break;424 break;
425 size *= 2;425 size *= 2;
426 }426 }
tests/tests2/60_errors_and_warnings.c+3−0
@@ -201,6 +201,9 @@ void * _Alignas(16) p1; · 200 unmodified lines
201 _Static_assert(1);201 _Static_assert(1);
202 _Static_assert(0);202 _Static_assert(0);
203 203
204#elif defined test_static_assert_empty_string
205 _Static_assert(0,"");
206
204#elif defined test_void_array207#elif defined test_void_array
205 void t[3];208 void t[3];
206 209
tests/tests2/60_errors_and_warnings.expect+34−31
@@ -100,22 +100,25 @@ · 99 unmodified lines
100[test_static_assert_c2x]100[test_static_assert_c2x]
10160_errors_and_warnings.c:202: error: _Static_assert fail10160_errors_and_warnings.c:202: error: _Static_assert fail
102 102
103[test_static_assert_empty_string]
10460_errors_and_warnings.c:205: error:
105
103[test_void_array]106[test_void_array]
10460_errors_and_warnings.c:205: error: declaration of an array of incomplete type elements10760_errors_and_warnings.c:208: error: declaration of an array of incomplete type elements
105 108
106[test_incomplete_enum_array]109[test_incomplete_enum_array]
10760_errors_and_warnings.c:208: error: declaration of an array of incomplete type elements11060_errors_and_warnings.c:211: error: declaration of an array of incomplete type elements
108 111
109[test_incomplete_struct_array]112[test_incomplete_struct_array]
11060_errors_and_warnings.c:211: error: declaration of an array of incomplete type elements11360_errors_and_warnings.c:214: error: declaration of an array of incomplete type elements
111 114
112[test_const_fun_array]115[test_const_fun_array]
11360_errors_and_warnings.c:215: error: declaration of an array of functions11660_errors_and_warnings.c:218: error: declaration of an array of functions
114 117
115[test_incomplete_array_array]118[test_incomplete_array_array]
116 119
117[test_extern_array]120[test_extern_array]
11860_errors_and_warnings.c:231: error: incompatible types for redefinition of 'x'12160_errors_and_warnings.c:234: error: incompatible types for redefinition of 'x'
119 122
120[test_func_1]123[test_func_1]
121hello: a = 123124hello: a = 123
@@ -124,17 +127,17 @@ hello: a = 123 · 2 unmodified lines
124hello: a = 123127hello: a = 123
125 128
126[test_func_3]129[test_func_3]
12760_errors_and_warnings.c:261: warning: static storage ignored for redefinition of 'hello'13060_errors_and_warnings.c:264: warning: static storage ignored for redefinition of 'hello'
128hello: a = 123131hello: a = 123
129 132
130[test_func_4]133[test_func_4]
131hello: a = 123134hello: a = 123
132 135
133[test_func_5]136[test_func_5]
13460_errors_and_warnings.c:261: error: incompatible types for redefinition of 'hello'13760_errors_and_warnings.c:264: error: incompatible types for redefinition of 'hello'
135 138
136[test_func_6]139[test_func_6]
13760_errors_and_warnings.c:249: error: function without file scope cannot be static14060_errors_and_warnings.c:252: error: function without file scope cannot be static
138 141
139[test_var_1]142[test_var_1]
140main : 1 ; 1143main : 1 ; 1
@@ -147,68 +150,68 @@ main : 2 ; 2 · 6 unmodified lines
147bar : 3 ; 3150bar : 3 ; 3
148 151
149[test_var_3]152[test_var_3]
15060_errors_and_warnings.c:293: error: incompatible types for redefinition of 'xxx'15360_errors_and_warnings.c:296: error: incompatible types for redefinition of 'xxx'
151 154
152[test_var_4]155[test_var_4]
153 156
154[test_long_double_type_for_win32]157[test_long_double_type_for_win32]
15560_errors_and_warnings.c:324: warning: assignment from incompatible pointer type15860_errors_and_warnings.c:327: warning: assignment from incompatible pointer type
156 159
157[test_stray_backslash]160[test_stray_backslash]
15860_errors_and_warnings.c:330: error: stray '\' in program16160_errors_and_warnings.c:333: error: stray '\' in program
159 162
160[test_stray_backslash2]163[test_stray_backslash2]
161\n164\n
162 165
163[test_var_array]166[test_var_array]
16460_errors_and_warnings.c:345: error: flexible array has zero size in this context16760_errors_and_warnings.c:348: error: flexible array has zero size in this context
165 168
166[test_var_array2]169[test_var_array2]
16760_errors_and_warnings.c:355: error: flexible array has zero size in this context17060_errors_and_warnings.c:358: error: flexible array has zero size in this context
168 171
169[test_var_array3]172[test_var_array3]
17060_errors_and_warnings.c:362: error: flexible array has zero size in this context17360_errors_and_warnings.c:365: error: flexible array has zero size in this context
171 174
172[test_default_int_type]175[test_default_int_type]
17360_errors_and_warnings.c:365: warning: type defaults to int17660_errors_and_warnings.c:368: warning: type defaults to int
174 177
175[test_invalid_global_stmtexpr]178[test_invalid_global_stmtexpr]
17660_errors_and_warnings.c:369: error: statement expression outside of function17960_errors_and_warnings.c:372: error: statement expression outside of function
177 180
178[test_invalid_tokckill]181[test_invalid_tokckill]
17960_errors_and_warnings.c:372: error: ';' expected (got "3")18260_errors_and_warnings.c:375: error: ';' expected (got "3")
180 183
181[test_duplicate_member]184[test_duplicate_member]
18260_errors_and_warnings.c:378: error: duplicate member 'a'18560_errors_and_warnings.c:381: error: duplicate member 'a'
183 186
184[test_duplicate_member_anon]187[test_duplicate_member_anon]
18560_errors_and_warnings.c:391: error: duplicate member 'd'18860_errors_and_warnings.c:394: error: duplicate member 'd'
186 189
187[test_conflicting_array_definition]190[test_conflicting_array_definition]
18860_errors_and_warnings.c:396: error: incompatible types for redefinition of 'array'19160_errors_and_warnings.c:399: error: incompatible types for redefinition of 'array'
189 192
190[test_cast_from_void]193[test_cast_from_void]
19160_errors_and_warnings.c:400: error: cannot convert 'void' to 'int'19460_errors_and_warnings.c:403: error: cannot convert 'void' to 'int'
192 195
193[test_switch_W1]196[test_switch_W1]
19460_errors_and_warnings.c:416: warning: implicit declaration of function 'fink'19760_errors_and_warnings.c:419: warning: implicit declaration of function 'fink'
195 198
196[test_switch_W2]199[test_switch_W2]
19760_errors_and_warnings.c:407: warning: unsupported option '-Wstuff'20060_errors_and_warnings.c:410: warning: unsupported option '-Wstuff'
19860_errors_and_warnings.c:418: warning: 'stuff' attribute ignored20160_errors_and_warnings.c:421: warning: 'stuff' attribute ignored
199 202
200[test_switch_W3]203[test_switch_W3]
20160_errors_and_warnings.c:415: error: assignment discards qualifiers from pointer target type20460_errors_and_warnings.c:418: error: assignment discards qualifiers from pointer target type
202 205
203[test_switch_W4]206[test_switch_W4]
20460_errors_and_warnings.c:416: warning: implicit declaration of function 'fink'20760_errors_and_warnings.c:419: warning: implicit declaration of function 'fink'
20560_errors_and_warnings.c:418: error: 'stuff' attribute ignored20860_errors_and_warnings.c:421: error: 'stuff' attribute ignored
206 209
207[test_invalid_funcparam_1]210[test_invalid_funcparam_1]
20860_errors_and_warnings.c:421: error: redeclaration of 'a'21160_errors_and_warnings.c:424: error: redeclaration of 'a'
209 212
210[test_invalid_funcparam_2]213[test_invalid_funcparam_2]
21160_errors_and_warnings.c:424: error: identifier expected21460_errors_and_warnings.c:427: error: identifier expected
212 215
213[test_array_funcparam]216[test_array_funcparam]
214arg[0] = "X"217arg[0] = "X"
@@ -218,7 +221,7 @@ arg[1] = "Y" · 3 unmodified lines
218[returns 78]221[returns 78]
219 222
220[test_illegal_unicode]223[test_illegal_unicode]
22160_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character22460_errors_and_warnings.c:451: error: 0xffffffff is not a valid universal character
222 225
223[test_error_string]226[test_error_string]
22460_errors_and_warnings.c:453: error: #error \123\45622760_errors_and_warnings.c:456: error: #error \123\456

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t