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*.
This commit is contained in:
parent
644143c8e1
commit
ab5c9f60b7
5 changed files with 61 additions and 5 deletions
24
gdb/eval.c
24
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue