aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@home.transmeta.com>2003-04-04 10:49:08 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:09 -0700
commit51d392ef668ec4125abfc0463587c15fdd4f8f8d (patch)
tree47542ad5274a5b51676b588b01948cf54c7e2cf9
parent112e133ea8c6ca654a44ae555741da9dca385499 (diff)
downloadsparse-dev-51d392ef668ec4125abfc0463587c15fdd4f8f8d.tar.gz
Update 'addressof' to work with the new symbol setup.
-rw-r--r--evaluate.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/evaluate.c b/evaluate.c
index fede2855..6e3515df 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -656,27 +656,18 @@ static struct symbol *evaluate_addressof(struct expression *expr)
struct symbol *ctype, *symbol;
struct expression *op = expr->unop;
-
- ctype = op->ctype;
-
- /* Simplify: &*(expr) => (expr) */
- if (op->type == EXPR_PREOP && op->op == '*') {
- *expr = *op->unop;
+ if (op->type != EXPR_PREOP || op->op != '*') {
+ warn(expr->pos, "not an lvalue");
+ return NULL;
}
-
+ ctype = op->ctype;
symbol = alloc_symbol(expr->pos, SYM_PTR);
symbol->ctype.base_type = ctype;
symbol->ctype.alignment = POINTER_ALIGNMENT;
symbol->bit_size = BITS_IN_POINTER;
+
+ *expr = *op->unop;
expr->ctype = symbol;
- if (expr->unop->type == EXPR_SYMBOL) {
- struct symbol *var = expr->unop->symbol;
- if (var->ctype.modifiers & MOD_REGISTER) {
- warn(expr->pos, "register variable and address-of do not mix");
- var->ctype.modifiers &= ~MOD_REGISTER;
- }
- var->ctype.modifiers |= MOD_ADDRESSABLE;
- }
return symbol;
}