aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorDaniel Glöckner <daniel-gl@gmx.net>2008-11-20 11:39:28 +0100
committergrischka <grischka>2008-11-30 07:21:42 +0100
commitdeb410710cc3f2128521dd37fdbd2bc0216a5e67 (patch)
tree4b8acaf29b7156872e39674cda4a9f9cc9f1341d /tcc.c
parent1b599ea7f8614b19762816d35eef467b8c9bd178 (diff)
downloadtinycc-deb410710cc3f2128521dd37fdbd2bc0216a5e67.tar.gz
tinycc-deb410710cc3f2128521dd37fdbd2bc0216a5e67.tar.bz2
Rewrote '?' for constants
The condition is now cast to _Bool and it now works with return types bigger than 32 bit.
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/tcc.c b/tcc.c
index 100db98..5d4999e 100644
--- a/tcc.c
+++ b/tcc.c
@@ -7980,23 +7980,26 @@ static void expr_eq(void)
CType type, type1, type2;
if (const_wanted) {
- int c1, c;
expr_lor_const();
if (tok == '?') {
+ CType boolean;
+ int c;
+ boolean.t = VT_BOOL;
+ vdup();
+ gen_cast(&boolean);
c = vtop->c.i;
vpop();
next();
- if (tok == ':' && gnu_ext) {
- c1 = c;
- } else {
- gexpr();
- c1 = vtop->c.i;
+ if (tok != ':' || !gnu_ext) {
vpop();
+ gexpr();
}
+ if (!c)
+ vpop();
skip(':');
expr_eq();
if (c)
- vtop->c.i = c1;
+ vpop();
}
} else {
expr_lor();