aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-22 22:57:40 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-22 22:57:40 +0200
commitb56dffd9a7f810dbbf264cd4060e6160556bd02c (patch)
tree0f1bbf687469e5214bade2bac68b1bff4198c853
parent6d8cfa9b42cf12eff46793758345783df28beaad (diff)
Default untyped numeric constants to ints
-rw-r--r--src/analyzer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/analyzer.c b/src/analyzer.c
index f665d4c..b16a2eb 100644
--- a/src/analyzer.c
+++ b/src/analyzer.c
@@ -215,9 +215,11 @@ analyzedecl(struct azctx ctx, scope_t *scps, type_t *types, ast_t ast,
} else
ni = fwdnode(ast, i);
- if (ltype.kind == TYPE_UNSET)
+ if (ltype.kind == TYPE_UNSET) {
ltype = rtype;
- else if (!typecompat(ltype, rtype))
+ if (ast.kinds[i] == ASTDECL && rtype.size == 0)
+ ltype.size = 8;
+ } else if (!typecompat(ltype, rtype))
err("analyzer: Type mismatch");
types[i] = ltype;