aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@home.transmeta.com>2003-03-25 12:24:00 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 20:59:45 -0700
commit1c5968beb66fc631e74fd2ddacaf4c4da52b90cc (patch)
tree2663559b4b51011a8433855ae855df46312ed181
parent50693db0e53525b90459a31b8f5bc6449538565a (diff)
downloadsparse-dev-1c5968beb66fc631e74fd2ddacaf4c4da52b90cc.tar.gz
Evaluate pre-op expression types.
-rw-r--r--evaluate.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index c9c16a45..c962d961 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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)