From 6ec0392311952ab4a2d621f39cc082bcc2f5bf9e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 9 Jul 2024 16:18:34 +0200 Subject: Throw error when assigning non-const to :: --- src/analyzer.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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 */ -- cgit v1.2.3