Addresses of non-weak symbols are non-zero

Use this fact in some foldings of comparisons.  See testcase.
This commit is contained in:
Michael Matz
2016-08-15 05:19:12 +02:00
parent be6d8ffc10
commit d720865fb6
2 changed files with 13 additions and 1 deletions

View File

@ -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;