scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 101edd9a3b5d71aecd5ed30c70b2ad011e27a66d
parent cd9f71bbfc1f5bf8fc7a63931c29cce9acabda97
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 26 Aug 2015 22:22:05 +0200

Emit pointer constants

Pointer constants have the same representation than TUINT values,
so they can share the code.

Diffstat:
Mcc1/code.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -181,10 +181,14 @@ emitconst(Node *np) { char *bp, c; Symbol *sym = np->sym; + Type *tp = np->type; + TUINT u; - switch (BTYPE(np)) { + switch (tp->op) { + case PTR: case INT: - printf("#%c%lX", np->type->letter, (long) sym->u.i); + u = (tp->sign) ? (TUINT) sym->u.i : sym->u.u; + printf("#%c%lX", np->type->letter, sym->u.i); break; case ARY: /*