History

Revert "Disable C99 VLA when alloca is unavailable."

This reverts commit e3e5d4ad7a475e30ea13ad1ba9f23e6210d5d431.

Thomas Preud'homme committed 15 years ago

Commit 4b8470f1 parent b0c50fb2 files · +2 −10Browse files

Unified · Split

2 files
  1. tccgen.c +0 −8
  2. tests/tcctest.c +2 −2
tccgen.c+0−8
@@ -3162,21 +3162,17 @@ static void post_type(CType *type, AttributeDef *ad) · 3161 unmodified lines
31623162 n = -1;
31633163 if (tok != ']') {
31643164 gexpr();
3165−#ifdef TOK_alloca
31663165 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
3167−#endif
31683166 n = vtop->c.i;
31693167 last_vtop = vtop;
31703168 if (n < 0)
31713169 error("invalid array size");
3172−#ifdef TOK_alloca
31733170 } else {
31743171 if (!is_integer_btype(vtop->type.t & VT_BTYPE))
31753172 error("size of variable length array should be an integer");
31763173 type->t |= VT_VLA;
31773174 last_vtop = vtop;
31783175 }
3179−#endif
31803176 }
31813177 skip(']');
31823178 /* parse next post type */
@@ -4868,11 +4864,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 1685 unmodified lines
48684864 int a;
48694865 CValue retcval;
48704866
4871−/* No need to coment all the block as it will never be called without
4872− TOK_alloca defined (See ifdef TOK_alloca stanza in post_type */
4873−#ifdef TOK_alloca
48744867 vpush_global_sym(&func_old_type, TOK_alloca);
4875−#endif
48764868 vla_runtime_type_size(type, &a);
48774869 gfunc_call(1);
48784870
tests/tcctest.c+2−2
@@ -2010,7 +2010,7 @@ void old_style_function(void) · 2009 unmodified lines
20102010
20112011 void alloca_test()
20122012 {
2013−#ifdef TOK_alloca
2013+#if defined __i386__ || defined __x86_64__
20142014 char *p = alloca(16);
20152015 strcpy(p,"123456789012345");
20162016 printf("alloca: p is %s\n", p);
@@ -2022,7 +2022,7 @@ void alloca_test() · 5 unmodified lines
20222022
20232023 void c99_vla_test(int size1, int size2)
20242024 {
2025−#ifdef TOK_alloca
2025+#if defined __i386__ || defined __x86_64__
20262026 int tab1[size1 * size2][2], tab2[10][2];
20272027 void *tab1_ptr, *tab2_ptr;
20282028