mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-26 12:04:59 +08:00
Fix binding of assignment expressions.
This commit is contained in:
parent
9228842fa7
commit
14673d0c49
58
tccgen.c
58
tccgen.c
@ -3766,38 +3766,15 @@ ST_FUNC void unary(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uneq(void)
|
|
||||||
{
|
|
||||||
int t;
|
|
||||||
|
|
||||||
unary();
|
|
||||||
if (tok == '=' ||
|
|
||||||
(tok >= TOK_A_MOD && tok <= TOK_A_DIV) ||
|
|
||||||
tok == TOK_A_XOR || tok == TOK_A_OR ||
|
|
||||||
tok == TOK_A_SHL || tok == TOK_A_SAR) {
|
|
||||||
test_lvalue();
|
|
||||||
t = tok;
|
|
||||||
next();
|
|
||||||
if (t == '=') {
|
|
||||||
expr_eq();
|
|
||||||
} else {
|
|
||||||
vdup();
|
|
||||||
expr_eq();
|
|
||||||
gen_op(t & 0x7f);
|
|
||||||
}
|
|
||||||
vstore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ST_FUNC void expr_prod(void)
|
ST_FUNC void expr_prod(void)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
uneq();
|
unary();
|
||||||
while (tok == '*' || tok == '/' || tok == '%') {
|
while (tok == '*' || tok == '/' || tok == '%') {
|
||||||
t = tok;
|
t = tok;
|
||||||
next();
|
next();
|
||||||
uneq();
|
unary();
|
||||||
gen_op(t);
|
gen_op(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3949,7 +3926,7 @@ static void expr_lor(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: better constant handling */
|
/* XXX: better constant handling */
|
||||||
static void expr_eq(void)
|
static void expr_cond(void)
|
||||||
{
|
{
|
||||||
int tt, u, r1, r2, rc, t1, t2, bt1, bt2;
|
int tt, u, r1, r2, rc, t1, t2, bt1, bt2;
|
||||||
SValue sv;
|
SValue sv;
|
||||||
@ -3973,7 +3950,7 @@ static void expr_eq(void)
|
|||||||
if (!c)
|
if (!c)
|
||||||
vpop();
|
vpop();
|
||||||
skip(':');
|
skip(':');
|
||||||
expr_eq();
|
expr_cond();
|
||||||
if (c)
|
if (c)
|
||||||
vpop();
|
vpop();
|
||||||
}
|
}
|
||||||
@ -4010,7 +3987,7 @@ static void expr_eq(void)
|
|||||||
skip(':');
|
skip(':');
|
||||||
u = gjmp(0);
|
u = gjmp(0);
|
||||||
gsym(tt);
|
gsym(tt);
|
||||||
expr_eq();
|
expr_cond();
|
||||||
type2 = vtop->type;
|
type2 = vtop->type;
|
||||||
|
|
||||||
t1 = type1.t;
|
t1 = type1.t;
|
||||||
@ -4090,6 +4067,29 @@ static void expr_eq(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void expr_eq(void)
|
||||||
|
{
|
||||||
|
int t;
|
||||||
|
|
||||||
|
expr_cond();
|
||||||
|
if (tok == '=' ||
|
||||||
|
(tok >= TOK_A_MOD && tok <= TOK_A_DIV) ||
|
||||||
|
tok == TOK_A_XOR || tok == TOK_A_OR ||
|
||||||
|
tok == TOK_A_SHL || tok == TOK_A_SAR) {
|
||||||
|
test_lvalue();
|
||||||
|
t = tok;
|
||||||
|
next();
|
||||||
|
if (t == '=') {
|
||||||
|
expr_eq();
|
||||||
|
} else {
|
||||||
|
vdup();
|
||||||
|
expr_eq();
|
||||||
|
gen_op(t & 0x7f);
|
||||||
|
}
|
||||||
|
vstore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ST_FUNC void gexpr(void)
|
ST_FUNC void gexpr(void)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -4134,7 +4134,7 @@ static void expr_const1(void)
|
|||||||
int a;
|
int a;
|
||||||
a = const_wanted;
|
a = const_wanted;
|
||||||
const_wanted = 1;
|
const_wanted = 1;
|
||||||
expr_eq();
|
expr_cond();
|
||||||
const_wanted = a;
|
const_wanted = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user