aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 63961cc..539b700 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1,6 +1,6 @@
/* Evaluate expressions for GDB.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ Copyright (C) 1986-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -994,9 +994,10 @@ add_struct_fields (struct type *type, completion_list &output,
output.emplace_back (concat (prefix, type->field (i).name (),
nullptr));
}
- else if (type->field (i).type ()->code () == TYPE_CODE_UNION)
+ else if (type->field (i).type ()->code () == TYPE_CODE_UNION
+ || type->field (i).type ()->code () == TYPE_CODE_STRUCT)
{
- /* Recurse into anonymous unions. */
+ /* Recurse into anonymous unions and structures. */
add_struct_fields (type->field (i).type (),
output, fieldname, namelen, prefix);
}
@@ -2557,27 +2558,26 @@ unop_extract_operation::evaluate (struct type *expect_type,
}
-
/* Helper for evaluate_subexp_for_address. */
static value *
-evaluate_subexp_for_address_base (struct expression *exp, enum noside noside,
- value *x)
+evaluate_subexp_for_address_base (enum noside noside, value *x)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = check_typedef (x->type ());
+ enum type_code typecode = type->code ();
if (TYPE_IS_REFERENCE (type))
return value::zero (lookup_pointer_type (type->target_type ()),
- not_lval);
- else if (x->lval () == lval_memory || value_must_coerce_to_target (x))
- return value::zero (lookup_pointer_type (x->type ()),
- not_lval);
+ not_lval);
+ else if (x->lval () == lval_memory || value_must_coerce_to_target (x)
+ || typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
+ return value::zero (lookup_pointer_type (x->type ()), not_lval);
else
- error (_("Attempt to take address of "
- "value not located in memory."));
+ error (_("Attempt to take address of value not located in memory."));
}
+
return value_addr (x);
}
@@ -2597,7 +2597,7 @@ value *
operation::evaluate_for_address (struct expression *exp, enum noside noside)
{
value *val = evaluate (nullptr, exp, noside);
- return evaluate_subexp_for_address_base (exp, noside, val);
+ return evaluate_subexp_for_address_base (noside, val);
}
value *
@@ -2624,7 +2624,7 @@ unop_ind_base_operation::evaluate_for_address (struct expression *exp,
if (unop_user_defined_p (UNOP_IND, x))
{
x = value_x_unop (x, UNOP_IND, noside);
- return evaluate_subexp_for_address_base (exp, noside, x);
+ return evaluate_subexp_for_address_base (noside, x);
}
return coerce_array (x);