* 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.
+2010-11-03 Ken Werner <ken.werner@de.ibm.com>
+
+ * 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.
+
2010-11-02 Doug Evans <dje@google.com>
New python module gdb.printing, and new commands info pretty-printer,
}
else
{
+ arg3 = value_non_lval (arg1);
+
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, 1);
else
}
value_assign (arg1, arg2);
- return arg1;
+ return arg3;
}
case UNOP_POSTDECREMENT:
}
else
{
+ arg3 = value_non_lval (arg1);
+
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, -1);
else
}
value_assign (arg1, arg2);
- return arg1;
+ return arg3;
}
case OP_THIS:
+2010-11-03 Ken Werner <ken.werner@de.ibm.com>
+
+ * gdb.base/exprs.exp: Add tests for pre-/post- in-/decrement operators.
+
2010-11-02 Doug Evans <dje@google.com>
* gdb.python/py-pp-maint.c: New file.
test_expr "print red" "\\$\[0-9\]* = red"
test_expr "print/d red" "\\$\[0-9\]* = 0"
gdb_test "set output-radix 10" ".*"
+
+# Pre-/post in-/decrement tests.
+gdb_test "set variable v_int = 1" ""
+gdb_test "print v_int++" "\\$\[0-9\]* = 1"
+gdb_test "print ++v_int" "\\$\[0-9\]* = 3"
+gdb_test "print v_int--" "\\$\[0-9\]* = 3"
+gdb_test "print --v_int" "\\$\[0-9\]* = 1"
+gdb_test "print v_int++ = 5" "Left operand of assignment is not an lvalue."
+gdb_test "print v_int-- = 5" "Left operand of assignment is not an lvalue."
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)
extern struct value *value_copy (struct value *);
+extern struct value *value_non_lval (struct value *);
+
extern void preserve_one_value (struct value *, struct objfile *, htab_t);
/* From valops.c */