diff options
| author | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-12-31 17:47:51 +0100 |
|---|---|---|
| committer | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-12-31 17:47:51 +0100 |
| commit | 14fa1f65352b15fef5e4b2c34848e7da660cc14f (patch) | |
| tree | c48095247d7cb7238114bc3d4f6999e139a75081 /bootstrap/outstmt.c | |
| parent | b3eefcddbf3c64cf16587af28c23576e18cdc832 (diff) | |
| download | slul-try2-main.tar.gz slul-try2-main.zip | |
Diffstat (limited to 'bootstrap/outstmt.c')
| -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; |
