History

re-added negative-array-size testcase and fixed fix for it

Joe Soroka committed 15 years ago

Commit 9b52e161 parent d7d84582 files · +5 −3Browse files

Unified · Split

2 files
  1. tccgen.c +3 −3
  2. tests/tcctest.c +2 −0
tccgen.c+3−3
@@ -3166,13 +3166,13 @@ static void post_type(CType *type, AttributeDef *ad) · 3165 unmodified lines
31663166 n = -1;
31673167 t1 = 0;
31683168 if (tok != ']') {
3169− gexpr();
3169+ if (!local_stack || nocode_wanted)
3170+ vpushi(expr_const());
3171+ else gexpr();
31703172 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
31713173 n = vtop->c.i;
31723174 if (n < 0)
31733175 error("invalid array size");
3174− } else if (!local_stack) {
3175− error("expected constant expression (variably modified array at file scope)");
31763176 } else {
31773177 if (!is_integer_btype(vtop->type.t & VT_BTYPE))
31783178 error("size of variable length array should be an integer");
tests/tcctest.c+2−0
@@ -2083,6 +2083,8 @@ void *bounds_checking_is_enabled() · 2082 unmodified lines
20832083 return (ca != cp + 1) ? cp : NULL;
20842084 }
20852085
2086+typedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];
2087+
20862088 void c99_vla_test(int size1, int size2)
20872089 {
20882090 #if defined __i386__ || defined __x86_64__

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