summaryrefslogtreecommitdiff
path: root/parse/fold.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-02-14 22:55:11 -0800
committerOri Bernstein <ori@eigenstate.org>2017-02-14 22:55:11 -0800
commit41e2a4f9b568b784c97b285c908409d8879a42a4 (patch)
tree1a880dd4dd86f63162af4b5cbe9b4efa15def6dd /parse/fold.c
parent9d11b6dbcecb0ed2013043bbff1dea9ac0355c7b (diff)
downloadmc-41e2a4f9b568b784c97b285c908409d8879a42a4.tar.gz
Fold Utags on union literals.
Diffstat (limited to 'parse/fold.c')
-rw-r--r--parse/fold.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/parse/fold.c b/parse/fold.c
index 6139293..66d8d43 100644
--- a/parse/fold.c
+++ b/parse/fold.c
@@ -121,6 +121,7 @@ Node *fold(Node *n, int foldvar)
Node **args, *r;
Type *t;
vlong a, b;
+ Ucon *uc;
size_t i;
if (!n)
@@ -135,6 +136,12 @@ Node *fold(Node *n, int foldvar)
for (i = 0; i < n->expr.nargs; i++)
args[i] = fold(args[i], foldvar);
switch (exprop(n)) {
+ case Outag:
+ if (exprop(args[0]) != Oucon)
+ break;
+ uc = finducon(tybase(exprtype(args[0])), args[0]->expr.args[0]);
+ r = val(n->loc, uc->id, exprtype(n));
+ break;
case Ovar:
if (foldvar && issmallconst(decls[n->expr.did]))
r = fold(decls[n->expr.did]->decl.init, foldvar);