aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-07-25 04:24:50 +0000
committerDaniel Jacobowitz <drow@false.org>2006-07-25 04:24:50 +0000
commitab5c9f60b7114072882b15531228a1ec8ce4bafd (patch)
tree822ef7d2eb63a6a38bed18ae33626bf190eec9ad /gdb/eval.c
parent644143c8e18a13bf2da11dbb1d6dd937e6104ff4 (diff)
downloadgdb-ab5c9f60b7114072882b15531228a1ec8ce4bafd.zip
gdb-ab5c9f60b7114072882b15531228a1ec8ce4bafd.tar.gz
gdb-ab5c9f60b7114072882b15531228a1ec8ce4bafd.tar.bz2
gdb/
* eval.c (evaluate_subexp_for_address): Don't incorrectly discard calls to C++ operator*. gdb/testsuite/ * gdb.cp/userdef.cc, gdb.cp/userdef.exp: New tests for unary operator*.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 083bbc2..d5d8969 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2132,6 +2132,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
enum exp_opcode op;
int pc;
struct symbol *var;
+ struct value *x;
pc = (*pos);
op = exp->elts[pc].opcode;
@@ -2140,7 +2141,24 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
{
case UNOP_IND:
(*pos)++;
- return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+ /* We can't optimize out "&*" if there's a user-defined operator*. */
+ if (unop_user_defined_p (op, x))
+ {
+ x = value_x_unop (x, op, noside);
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ if (VALUE_LVAL (x) == lval_memory)
+ return value_zero (lookup_pointer_type (value_type (x)),
+ not_lval);
+ else
+ error (_("Attempt to take address of non-lval"));
+ }
+ return value_addr (x);
+ }
+
+ return x;
case UNOP_MEMVAL:
(*pos) += 3;
@@ -2179,16 +2197,16 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
default:
default_case:
+ x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
- struct value *x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (VALUE_LVAL (x) == lval_memory)
return value_zero (lookup_pointer_type (value_type (x)),
not_lval);
else
error (_("Attempt to take address of non-lval"));
}
- return value_addr (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ return value_addr (x);
}
}