scc

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

commit 235aee1ffddb12ecbab5823365199931283e5ea4
parent b4d92e02bc635472f47ca877add11b4581392238
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 15 Apr 2014 13:24:59 +0200

Add unary *

These operator take the content of a pointer.

Diffstat:
Mexpr.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/expr.c b/expr.c @@ -395,7 +395,7 @@ unary(void) return incdec(unary(), op); /* TODO: unary or cast? */ case '!': op = OEXC; break; case '&': op = OADDR; break; - /* TODO: case '*': */ + case '*': op = OPTR; break; case '+': op = OADD; break; case '~': op = OCPL; break; case '-': op = ONEG; break; @@ -408,6 +408,17 @@ unary(void) t = tp->op; switch (op) { + case OPTR: + switch (t) { + case ARY: case FTN: + np = addr2ptr(np); + case PTR: + tp = tp->type; + break; + default: + goto bad_operand; + } + break; case OADDR: if (!np->b.lvalue) goto no_lvalue;