aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-07-09 16:18:34 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-07-09 16:18:34 +0200
commit6ec0392311952ab4a2d621f39cc082bcc2f5bf9e (patch)
tree91215dd26ac08ab93c08b20f48f35e1676e216f5
parent244b63b06e32a69417b6b78c2213045196c731d2 (diff)
Throw error when assigning non-const to ::
-rw-r--r--src/analyzer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/analyzer.c b/src/analyzer.c
index 4b15e0a..515d7e4 100644
--- a/src/analyzer.c
+++ b/src/analyzer.c
@@ -298,6 +298,8 @@ analyzedecl(struct azctx *ctx, idx_t i)
rtype = ctx->types[p.rhs];
if (isstatic && !TESTBIT(ctx->cnst, p.rhs))
err("analyzer: Assigning non-constant expression to static");
+ if (isconst && !TESTBIT(ctx->cnst, p.rhs))
+ err("analyzer: Assigning non-constant expression to constant");
} else
ni = fwdnode(ctx->ast, i);
@@ -500,6 +502,7 @@ analyzeexpr(struct azctx *ctx, idx_t i)
return ni;
}
case ASTFN:
+ SETBIT(ctx->cnst, i);
return analyzefn(ctx, i);
case ASTFUNCALL: {
/* TODO: Support function arguments */