aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/outstmt.c
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2025-12-31 17:47:51 +0100
committerSamuel Lidén Borell <samuel@kodafritt.se>2025-12-31 17:47:51 +0100
commit14fa1f65352b15fef5e4b2c34848e7da660cc14f (patch)
treec48095247d7cb7238114bc3d4f6999e139a75081 /bootstrap/outstmt.c
parentb3eefcddbf3c64cf16587af28c23576e18cdc832 (diff)
downloadslul-try2-main.tar.gz
slul-try2-main.zip
bootstrap: Fix type of non-literal initialisersHEADmain
Diffstat (limited to 'bootstrap/outstmt.c')
-rw-r--r--bootstrap/outstmt.c11
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;