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
420420 va_copy(v, ap);
421421 len = vsnprintf((char*)cstr->data + cstr->size, size, fmt, v);
422422 va_end(v);
423− if (len > 0 && len < size)
423+ if (len >= 0 && len < size)
424424 break;
425425 size *= 2;
426426 }
tests/tests2/60_errors_and_warnings.c+3−0
@@ -201,6 +201,9 @@ void * _Alignas(16) p1; · 200 unmodified lines
201201 _Static_assert(1);
202202 _Static_assert(0);
203203
204+#elif defined test_static_assert_empty_string
205+ _Static_assert(0,"");
206+
204207 #elif defined test_void_array
205208 void t[3];
206209
tests/tests2/60_errors_and_warnings.expect+34−31
@@ -100,22 +100,25 @@ · 99 unmodified lines
100100 [test_static_assert_c2x]
101101 60_errors_and_warnings.c:202: error: _Static_assert fail
102102
103+[test_static_assert_empty_string]
104+60_errors_and_warnings.c:205: error:
105+
103106 [test_void_array]
104−60_errors_and_warnings.c:205: error: declaration of an array of incomplete type elements
107+60_errors_and_warnings.c:208: error: declaration of an array of incomplete type elements
105108
106109 [test_incomplete_enum_array]
107−60_errors_and_warnings.c:208: error: declaration of an array of incomplete type elements
110+60_errors_and_warnings.c:211: error: declaration of an array of incomplete type elements
108111
109112 [test_incomplete_struct_array]
110−60_errors_and_warnings.c:211: error: declaration of an array of incomplete type elements
113+60_errors_and_warnings.c:214: error: declaration of an array of incomplete type elements
111114
112115 [test_const_fun_array]
113−60_errors_and_warnings.c:215: error: declaration of an array of functions
116+60_errors_and_warnings.c:218: error: declaration of an array of functions
114117
115118 [test_incomplete_array_array]
116119
117120 [test_extern_array]
118−60_errors_and_warnings.c:231: error: incompatible types for redefinition of 'x'
121+60_errors_and_warnings.c:234: error: incompatible types for redefinition of 'x'
119122
120123 [test_func_1]
121124 hello: a = 123
@@ -124,17 +127,17 @@ hello: a = 123 · 2 unmodified lines
124127 hello: a = 123
125128
126129 [test_func_3]
127−60_errors_and_warnings.c:261: warning: static storage ignored for redefinition of 'hello'
130+60_errors_and_warnings.c:264: warning: static storage ignored for redefinition of 'hello'
128131 hello: a = 123
129132
130133 [test_func_4]
131134 hello: a = 123
132135
133136 [test_func_5]
134−60_errors_and_warnings.c:261: error: incompatible types for redefinition of 'hello'
137+60_errors_and_warnings.c:264: error: incompatible types for redefinition of 'hello'
135138
136139 [test_func_6]
137−60_errors_and_warnings.c:249: error: function without file scope cannot be static
140+60_errors_and_warnings.c:252: error: function without file scope cannot be static
138141
139142 [test_var_1]
140143 main : 1 ; 1
@@ -147,68 +150,68 @@ main : 2 ; 2 · 6 unmodified lines
147150 bar : 3 ; 3
148151
149152 [test_var_3]
150−60_errors_and_warnings.c:293: error: incompatible types for redefinition of 'xxx'
153+60_errors_and_warnings.c:296: error: incompatible types for redefinition of 'xxx'
151154
152155 [test_var_4]
153156
154157 [test_long_double_type_for_win32]
155−60_errors_and_warnings.c:324: warning: assignment from incompatible pointer type
158+60_errors_and_warnings.c:327: warning: assignment from incompatible pointer type
156159
157160 [test_stray_backslash]
158−60_errors_and_warnings.c:330: error: stray '\' in program
161+60_errors_and_warnings.c:333: error: stray '\' in program
159162
160163 [test_stray_backslash2]
161164 \n
162165
163166 [test_var_array]
164−60_errors_and_warnings.c:345: error: flexible array has zero size in this context
167+60_errors_and_warnings.c:348: error: flexible array has zero size in this context
165168
166169 [test_var_array2]
167−60_errors_and_warnings.c:355: error: flexible array has zero size in this context
170+60_errors_and_warnings.c:358: error: flexible array has zero size in this context
168171
169172 [test_var_array3]
170−60_errors_and_warnings.c:362: error: flexible array has zero size in this context
173+60_errors_and_warnings.c:365: error: flexible array has zero size in this context
171174
172175 [test_default_int_type]
173−60_errors_and_warnings.c:365: warning: type defaults to int
176+60_errors_and_warnings.c:368: warning: type defaults to int
174177
175178 [test_invalid_global_stmtexpr]
176−60_errors_and_warnings.c:369: error: statement expression outside of function
179+60_errors_and_warnings.c:372: error: statement expression outside of function
177180
178181 [test_invalid_tokckill]
179−60_errors_and_warnings.c:372: error: ';' expected (got "3")
182+60_errors_and_warnings.c:375: error: ';' expected (got "3")
180183
181184 [test_duplicate_member]
182−60_errors_and_warnings.c:378: error: duplicate member 'a'
185+60_errors_and_warnings.c:381: error: duplicate member 'a'
183186
184187 [test_duplicate_member_anon]
185−60_errors_and_warnings.c:391: error: duplicate member 'd'
188+60_errors_and_warnings.c:394: error: duplicate member 'd'
186189
187190 [test_conflicting_array_definition]
188−60_errors_and_warnings.c:396: error: incompatible types for redefinition of 'array'
191+60_errors_and_warnings.c:399: error: incompatible types for redefinition of 'array'
189192
190193 [test_cast_from_void]
191−60_errors_and_warnings.c:400: error: cannot convert 'void' to 'int'
194+60_errors_and_warnings.c:403: error: cannot convert 'void' to 'int'
192195
193196 [test_switch_W1]
194−60_errors_and_warnings.c:416: warning: implicit declaration of function 'fink'
197+60_errors_and_warnings.c:419: warning: implicit declaration of function 'fink'
195198
196199 [test_switch_W2]
197−60_errors_and_warnings.c:407: warning: unsupported option '-Wstuff'
198−60_errors_and_warnings.c:418: warning: 'stuff' attribute ignored
200+60_errors_and_warnings.c:410: warning: unsupported option '-Wstuff'
201+60_errors_and_warnings.c:421: warning: 'stuff' attribute ignored
199202
200203 [test_switch_W3]
201−60_errors_and_warnings.c:415: error: assignment discards qualifiers from pointer target type
204+60_errors_and_warnings.c:418: error: assignment discards qualifiers from pointer target type
202205
203206 [test_switch_W4]
204−60_errors_and_warnings.c:416: warning: implicit declaration of function 'fink'
205−60_errors_and_warnings.c:418: error: 'stuff' attribute ignored
207+60_errors_and_warnings.c:419: warning: implicit declaration of function 'fink'
208+60_errors_and_warnings.c:421: error: 'stuff' attribute ignored
206209
207210 [test_invalid_funcparam_1]
208−60_errors_and_warnings.c:421: error: redeclaration of 'a'
211+60_errors_and_warnings.c:424: error: redeclaration of 'a'
209212
210213 [test_invalid_funcparam_2]
211−60_errors_and_warnings.c:424: error: identifier expected
214+60_errors_and_warnings.c:427: error: identifier expected
212215
213216 [test_array_funcparam]
214217 arg[0] = "X"
@@ -218,7 +221,7 @@ arg[1] = "Y" · 3 unmodified lines
218221 [returns 78]
219222
220223 [test_illegal_unicode]
221−60_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character
224+60_errors_and_warnings.c:451: error: 0xffffffff is not a valid universal character
222225
223226 [test_error_string]
224−60_errors_and_warnings.c:453: error: #error \123\456
227+60_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