ref: bc18d36c3cf2e2ceea1e78a21242423d6878ed12
parent: 2ea781bea0442fe4526aa8fcf7336c28f2a120c8
author: Ori Bernstein <[email protected]>
date: Mon Jun 17 08:03:04 EDT 2013
Fix const inference for compound literals.
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -172,7 +172,7 @@
break;
case Nexpr:
ty = tystr(n->expr.type);
- fprintf(fd, " (type = %s, op = %s, flags = %d, did=%zd)\n",
+ fprintf(fd, " (type = %s, op = %s, isconst = %d, did=%zd)\n",
ty, opstr(n->expr.op), n->expr.isconst, n->expr.did);
free(ty);
for (i = 0; i < n->expr.nargs; i++)
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -749,7 +749,7 @@
*isconst = 1;
for (i = 0; i < n->lit.nelt; i++) {
infernode(st, n->lit.seqval[i], NULL, NULL);
- if (n->lit.seqval[i]->idxinit.init->expr.isconst)
+ if (!n->lit.seqval[i]->idxinit.init->expr.isconst)
*isconst = 0;
}
settype(st, n, mktyvar(n->line));
@@ -768,7 +768,7 @@
for (i = 0; i < n->lit.nelt; i++) {
infernode(st, n->lit.seqval[i], NULL, NULL);
unify(st, n, t->sub[0], type(st, n->lit.seqval[i]));
- if (n->lit.seqval[i]->idxinit.init->expr.isconst)
+ if (!n->lit.seqval[i]->idxinit.init->expr.isconst)
*isconst = 0;
}
settype(st, n, t);