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
3166 n = -1;3166 n = -1;
3167 t1 = 0;3167 t1 = 0;
3168 if (tok != ']') {3168 if (tok != ']') {
3169 gexpr();3169 if (!local_stack || nocode_wanted)
3170 vpushi(expr_const());
3171 else gexpr();
3170 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {3172 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
3171 n = vtop->c.i;3173 n = vtop->c.i;
3172 if (n < 0)3174 if (n < 0)
3173 error("invalid array size");3175 error("invalid array size");
3174 } else if (!local_stack) {
3175 error("expected constant expression (variably modified array at file scope)");
3176 } else {3176 } else {
3177 if (!is_integer_btype(vtop->type.t & VT_BTYPE))3177 if (!is_integer_btype(vtop->type.t & VT_BTYPE))
3178 error("size of variable length array should be an integer");3178 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
2083 return (ca != cp + 1) ? cp : NULL;2083 return (ca != cp + 1) ? cp : NULL;
2084}2084}
2085 2085
2086typedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];
2087
2086void c99_vla_test(int size1, int size2)2088void c99_vla_test(int size1, int size2)
2087{2089{
2088#if defined __i386__ || defined __x86_64__2090#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