summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-01-12 21:34:53 -0800
committerOri Bernstein <ori@eigenstate.org>2019-01-12 21:34:53 -0800
commitac58fd9b83d1bb1cac2a0fb354176dd975afd94c (patch)
treed4f1ab076665f862db9abcf40879d8cfb7b9c287
parent9f1ac5b4a1f2bb17b145c37f22bfc1b06432220e (diff)
downloadmc-ac58fd9b83d1bb1cac2a0fb354176dd975afd94c.tar.gz
Allow folding character-typed designated array inits.
-rw-r--r--parse/fold.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/parse/fold.c b/parse/fold.c
index da97bb5..2518a4b 100644
--- a/parse/fold.c
+++ b/parse/fold.c
@@ -23,9 +23,13 @@ getintlit(Node *n, vlong *v)
if (exprop(n) != Olit)
return 0;
l = n->expr.args[0];
- if (l->lit.littype != Lint)
+ /* It's up to type checking to make sure this is ok */
+ if (l->lit.littype == Lint)
+ *v = l->lit.intval;
+ else if (l->lit.littype == Lchr)
+ *v = l->lit.chrval;
+ else
return 0;
- *v = l->lit.intval;
return 1;
}