mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
Forbid VLA as static variables
Currently, VLA are not forbidden for static variable. This leads to problems even if for fixed-size array when the size expression uses the ternary operator (cond ? then-value : else-value) because it is parsed as a general expression which leads to code generated in this case. This commit solve the problem by forbidding VLA for static variables. Although not required for the fix, avoiding code generation when the expression is constant would be a nice addition though.
This commit is contained in:
parent
9966fd4eae
commit
85f6fad3a6
7
tccgen.c
7
tccgen.c
@ -3250,7 +3250,7 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td)
|
||||
{
|
||||
Sym *s;
|
||||
CType type1, *type2;
|
||||
int qualifiers, storage;
|
||||
int qualifiers, storage, saved_nocode_wanted;
|
||||
|
||||
while (tok == '*') {
|
||||
qualifiers = 0;
|
||||
@ -3304,7 +3304,12 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td)
|
||||
}
|
||||
storage = type->t & VT_STORAGE;
|
||||
type->t &= ~VT_STORAGE;
|
||||
if (storage & VT_STATIC) {
|
||||
saved_nocode_wanted = nocode_wanted;
|
||||
nocode_wanted = 1;
|
||||
}
|
||||
post_type(type, ad);
|
||||
nocode_wanted = saved_nocode_wanted;
|
||||
type->t |= storage;
|
||||
if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
|
||||
parse_attribute(ad);
|
||||
|
Loading…
Reference in New Issue
Block a user