From 84721b62c1f22ad91730ce7c468dab701a4034cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Gl=C3=B6ckner?= Date: Thu, 20 Nov 2008 11:39:28 +0100 Subject: [PATCH] Rewrote '?' for constants The condition is now cast to _Bool and it now works with return types bigger than 32 bit. --- tcc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tcc.c b/tcc.c index b17ff20b..f09f780b 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(); -- 2.11.4.GIT