aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-11-03 13:49:38 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-11-03 13:49:38 +0000
commitc37f7098e9cb05b2574cf82e6ae299530ed407ba (patch)
tree04d07481c7bee9f22662d80e56efecb1311ce103 /gdb/value.c
parent2ebf396434301f62203a5f1d3ada888af8dd193d (diff)
downloadgdb-c37f7098e9cb05b2574cf82e6ae299530ed407ba.zip
gdb-c37f7098e9cb05b2574cf82e6ae299530ed407ba.tar.gz
gdb-c37f7098e9cb05b2574cf82e6ae299530ed407ba.tar.bz2
gdb:
* value.h (value_non_lval): Declare. * value.c (value_non_lval): New function. * eval.c (evaluate_subexp_standard) <UNOP_POSTINCREMENT, UNOP_POSTDECREMENT>: Call value_non_lval to ensure to return a non-lvalue. gdb/testsuite: * gdb.base/exprs.exp: Add tests for pre-/post- in-/decrement operators.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/value.c b/gdb/value.c
index 55fcd38..381318b 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -826,6 +826,26 @@ value_copy (struct value *arg)
return val;
}
+/* Return a version of ARG that is non-lvalue. */
+
+struct value *
+value_non_lval (struct value *arg)
+{
+ if (VALUE_LVAL (arg) != not_lval)
+ {
+ struct type *enc_type = value_enclosing_type (arg);
+ struct value *val = allocate_value (enc_type);
+
+ memcpy (value_contents_all_raw (val), value_contents_all (arg),
+ TYPE_LENGTH (enc_type));
+ val->type = arg->type;
+ set_value_embedded_offset (val, value_embedded_offset (arg));
+ set_value_pointed_to_offset (val, value_pointed_to_offset (arg));
+ return val;
+ }
+ return arg;
+}
+
void
set_value_component_location (struct value *component,
const struct value *whole)