aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-08-15 05:19:12 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:10 +0100
commitd720865fb65d67acffb98d45eb7251d0102e2f9b (patch)
treea17c1de892117d58e199d1684b5b2d831923bb9d /tccgen.c
parentbe6d8ffc107db78d0542b5ee2d3306e7e132725c (diff)
downloadtinycc-d720865fb65d67acffb98d45eb7251d0102e2f9b.tar.gz
tinycc-d720865fb65d67acffb98d45eb7251d0102e2f9b.tar.bz2
Addresses of non-weak symbols are non-zero
Use this fact in some foldings of comparisons. See testcase.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index be5a8cb..27ea83f 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4979,7 +4979,9 @@ static void expr_cond(void)
expr_lor();
if (tok == '?') {
next();
- if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+ if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
+ (!(vtop->r & VT_SYM) ||
+ !(vtop->sym->type.t & VT_WEAK))) {
int saved_nocode_wanted = nocode_wanted;
CType boolean;
int c;