Le dimanche 31 juillet 2011 17:23:28, grischka a écrit :
> Thomas Preud'homme wrote:
> > Mmmmh good point, I should have tried with mob. I can't reproduce it
> > neither. So I guess master is not as close to mob as I thought.
> 
> Plus running the const_wanted branch without const_wanted being
> actually set doesn't look like a good idea.  It could still
> generate code in the gen_cast() or gexpr() calls below.
Thanks, I'll set (and unset at the end of the function) const_wanted in the 
next experimental upload. I was thinking about doing it each time 
cur_text_section is non NULL but it requires a static variable to store the 
previous value of const_wanted accross functions.
> 
> However note that tcc is still wrong with accepting VLA on the
> global level:
> 
>      int foo_array[fn() ? 2 : 42];
> 
> This should give an error such as with gcc:
> 
>      test.c:10: error: variable-size type declared outside of any function

Would the patch attached be satisfying or you prefer a better test for the 
global level?

> 
> Joe ?
> 
> Thanks,
> 
> --- grischka
diff --git a/tccgen.c b/tccgen.c
index e488c65..6aead92 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3174,6 +3174,8 @@ static void post_type(CType *type, AttributeDef *ad)
                 if (n < 0)
                     error("invalid array size");
             } else {
+                if (cur_text_section == NULL)
+                    error("variable length array declared outside of any function");
                 if (!is_integer_btype(vtop->type.t & VT_BTYPE))
                     error("size of variable length array should be an integer");
                 t1 = VT_VLA;

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to