diff options
| author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-03-25 12:24:00 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 20:59:45 -0700 |
| commit | 1c5968beb66fc631e74fd2ddacaf4c4da52b90cc (patch) | |
| tree | 2663559b4b51011a8433855ae855df46312ed181 | |
| parent | 50693db0e53525b90459a31b8f5bc6449538565a (diff) | |
| download | sparse-dev-1c5968beb66fc631e74fd2ddacaf4c4da52b90cc.tar.gz | |
Evaluate pre-op expression types.
| -rw-r--r-- | evaluate.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -160,7 +160,36 @@ static int evaluate_binop(struct expression *expr) static int evaluate_preop(struct expression *expr) { - return 0; + struct symbol *ctype = expr->unop->ctype; + + switch (expr->op) { + case '(': + expr->ctype = ctype; + return 1; + + case '*': + if (ctype->type != SYM_PTR) { + warn(expr->token, "cannot derefence this type"); + return 0; + } + expr->ctype = ctype->ctype.base_type; + return 1; + + case '&': { + struct symbol *symbol = alloc_symbol(expr->token, SYM_PTR); + symbol->ctype.base_type = ctype; + expr->ctype = symbol; + return 1; + } + + case '!': + expr->ctype = &bool_ctype; + return 1; + + default: + expr->ctype = ctype; + return 1; + } } static int evaluate_postop(struct expression *expr) |
