diff options
Diffstat (limited to 'bootstrap')
| -rw-r--r-- | bootstrap/outstmt.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bootstrap/outstmt.c b/bootstrap/outstmt.c index 847ff67..d02121b 100644 --- a/bootstrap/outstmt.c +++ b/bootstrap/outstmt.c @@ -26,12 +26,18 @@ enum AlwaysValue { ALWAYS_TRUE }; -static enum AlwaysValue always_value(const struct Expr *expr) +static const struct Expr *outermost_expr(const struct Expr *expr) { assert(expr != NULL); while (expr->rpnnext) { expr = expr->rpnnext; } + return expr; +} + +static enum AlwaysValue always_value(const struct Expr *expr) +{ + expr = outermost_expr(expr); if (!is_expr_const(expr)) return CAN_VARY; if (expr->kind == E_FALSE) return EXPLICIT_FALSE; if (expr->kind == E_TRUE) return EXPLICIT_TRUE; @@ -290,7 +296,8 @@ static void emit_single_statement(struct Stmt *stmt) if (!var->is_modifiable) { /* Non-modifiable variables are limited to the range of their initial value. */ - struct TypeRef *expr_tr = var->initval->typeref; + const struct TypeRef *expr_tr = + outermost_expr(var->initval)->typeref; if (var->typeref != expr_tr) { unsigned quals = var->typeref->quals; *var->typeref = *expr_tr; |
