aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-02-19 04:25:46 +0100
committerMichael Matz <matz@suse.de>2017-05-02 03:07:36 +0200
commit8b9697ca6b756af47eac153961abec70fd9dad6e (patch)
treed2c6f2247d2fa64ae22d1586194c96ce3155f775 /tccgen.c
parent24420bb5c091736d557b5941a32bd881f407731d (diff)
downloadtinycc-8b9697ca6b756af47eac153961abec70fd9dad6e.tar.gz
tinycc-8b9697ca6b756af47eac153961abec70fd9dad6e.tar.bz2
Fix bogus check for VT_LLOCAL types
VT_LLOCAL is a flag on .r, not on type.t. Fixing this requires minor surgery for compound literals which accidentally happened to be subsumed by the bogus test.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tccgen.c b/tccgen.c
index 8aa86f3..8d54ade 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4443,7 +4443,7 @@ ST_FUNC void unary(void)
there and in function calls. */
/* arrays can also be used although they are not lvalues */
if ((vtop->type.t & VT_BTYPE) != VT_FUNC &&
- !(vtop->type.t & VT_ARRAY) && !(vtop->type.t & VT_LLOCAL))
+ !(vtop->type.t & VT_ARRAY))
test_lvalue();
mk_pointer(&vtop->type);
gaddrof();
@@ -5954,12 +5954,15 @@ static void parse_init_elem(int expr_type)
global_expr = 1;
expr_const1();
global_expr = saved_global_expr;
- /* NOTE: symbols are accepted */
- if ((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST
+ /* NOTE: symbols are accepted, as well as lvalue for anon symbols
+ (compound literals). */
+ if (((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST
+ && ((vtop->r & (VT_SYM|VT_LVAL)) != (VT_SYM|VT_LVAL)
+ || vtop->sym->v < SYM_FIRST_ANOM))
#ifdef TCC_TARGET_PE
|| (vtop->type.t & VT_IMPORT)
#endif
- )
+ )
tcc_error("initializer element is not constant");
break;
case EXPR_ANY:
@@ -6711,6 +6714,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
/* push global reference */
sym = get_sym_ref(type, sec, addr, size);
vpushsym(type, sym);
+ vtop->r |= r;
}
#ifdef CONFIG_TCC_BCHECK