aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorBen Bacarisse <software@bsb.me.uk>2010-10-25 15:40:30 +0100
committerBen Bacarisse <software@bsb.me.uk>2010-10-25 15:40:30 +0100
commit14673d0c49156b42c3cd04a86c36906f338c7fee (patch)
tree082a5c71d9dc8f714e6f7c949bf6199ce34d1d1d /tccgen.c
parent9228842fa75190665241bf1d3bb3f8f74d2ffdbb (diff)
downloadtinycc-14673d0c49156b42c3cd04a86c36906f338c7fee.tar.gz
tinycc-14673d0c49156b42c3cd04a86c36906f338c7fee.tar.bz2
Fix binding of assignment expressions.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/tccgen.c b/tccgen.c
index ce7a420..82ec44f 100644
--- a/tccgen.c
+++ b/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)
{
int t;
- uneq();
+ unary();
while (tok == '*' || tok == '/' || tok == '%') {
t = tok;
next();
- uneq();
+ unary();
gen_op(t);
}
}
@@ -3949,7 +3926,7 @@ static void expr_lor(void)
}
/* XXX: better constant handling */
-static void expr_eq(void)
+static void expr_cond(void)
{
int tt, u, r1, r2, rc, t1, t2, bt1, bt2;
SValue sv;
@@ -3973,7 +3950,7 @@ static void expr_eq(void)
if (!c)
vpop();
skip(':');
- expr_eq();
+ expr_cond();
if (c)
vpop();
}
@@ -4010,7 +3987,7 @@ static void expr_eq(void)
skip(':');
u = gjmp(0);
gsym(tt);
- expr_eq();
+ expr_cond();
type2 = vtop->type;
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)
{
while (1) {
@@ -4134,7 +4134,7 @@ static void expr_const1(void)
int a;
a = const_wanted;
const_wanted = 1;
- expr_eq();
+ expr_cond();
const_wanted = a;
}