summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-01-06 11:58:31 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-01-06 13:01:38 -0500
commitd4009a2e458962548d4229f0c4d31789941c7721 (patch)
treed7995e96625d7fabdf4341172266a7f9e23eff57
parentdef83bb2ae78f12c5c9588bd6cdc639b8aaaf27e (diff)
small bugfix
-rw-r--r--.gitignore1
-rw-r--r--cgen.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index fae512f..bf94226 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
toc
a.out
out.c
+point.c
*.top
tests/**/*.c
tests/**/*.bin
diff --git a/cgen.c b/cgen.c
index 82857b0..cdeeec5 100644
--- a/cgen.c
+++ b/cgen.c
@@ -1769,7 +1769,6 @@ static bool cgen_decl(CGenerator *g, Declaration *d) {
}
} else {
/* declarations where we use an expression */
- assert(g->block && !(d->flags & DECL_IS_CONST));
int nidents = (int)arr_len(d->idents);
for (int idx = 0; idx < nidents; ++idx) {
Identifier i = d->idents[idx];
@@ -1787,6 +1786,7 @@ static bool cgen_decl(CGenerator *g, Declaration *d) {
cgen_write(g, "; ");
}
if (has_expr) {
+ assert(g->block && !(d->flags & DECL_IS_CONST));
if (!cgen_expr_pre(g, &d->expr)) return false;
if (d->expr.type.kind == TYPE_TUPLE) {
if (!cgen_set_tuple(g, NULL, d->idents, NULL, &d->expr)) return false;