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

This commit is contained in:
Joe Soroka 2011-07-22 02:09:28 -07:00
parent d7d8458888
commit 9b52e16a50
2 changed files with 5 additions and 3 deletions

View file

@ -3166,13 +3166,13 @@ static void post_type(CType *type, AttributeDef *ad)
n = -1;
t1 = 0;
if (tok != ']') {
gexpr();
if (!local_stack || nocode_wanted)
vpushi(expr_const());
else gexpr();
if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
n = vtop->c.i;
if (n < 0)
error("invalid array size");
} else if (!local_stack) {
error("expected constant expression (variably modified array at file scope)");
} else {
if (!is_integer_btype(vtop->type.t & VT_BTYPE))
error("size of variable length array should be an integer");

View file

@ -2083,6 +2083,8 @@ void *bounds_checking_is_enabled()
return (ca != cp + 1) ? cp : NULL;
}
typedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];
void c99_vla_test(int size1, int size2)
{
#if defined __i386__ || defined __x86_64__