From 2497b4984582be980b40913ef1bf561ccad2f265 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 29 Jun 2009 13:24:41 +0000 Subject: * value.h (value_subscript, value_subscripted_rvalue, value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * valarith.c (value_subscript, value_subscripted_rvalue, value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * wrapper.h (gdb_value_subscript): Use LONGEST instead of value as type of the index argument. * wrapper.c (gdb_value_subscript): Likewise. Update calls to gdb_value_subscript, value_subscript, value_subscripted_rvalue, value_bitstring_subscript and value_ptradd to use LONGEST instead of value as index argument type. Use value_ptradd instead of value_ptrsub. * ada-lang.c (ada_value_subscript, ada_value_ptr_subscript, ada_tag_name_2): Update. * ada-tasks.c (read_atcb): Update. * eval.c (evaluate_subexp_standard): Update. * valarith.c (value_subscript): Update. * gnu-v2-abi.c (gnuv2_virtual_fn_field): Update. * gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset, gnuv3_method_ptr_to_value): Update. * jv-lang.c (evaluate_subexp_java): Update. * m2-lang.c (evaluate_subexp_modula2): Update. * python/python-value.c (valpy_getitem, valpy_binop): Update. * wrapper.c (gdb_value_subscript): Update. * varobj.c (c_describe_child): Update. --- gdb/python/python-value.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 1b34f47..ab89842 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -293,7 +293,7 @@ valpy_getitem (PyObject *self, PyObject *key) if (idx == NULL) return NULL; - res_val = value_subscript (tmp, idx); + res_val = value_subscript (tmp, value_as_long (idx)); } } if (field) @@ -413,10 +413,12 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) CHECK_TYPEDEF (rtype); rtype = STRIP_REFERENCE (rtype); - if (TYPE_CODE (ltype) == TYPE_CODE_PTR) - res_val = value_ptradd (arg1, arg2); - else if (TYPE_CODE (rtype) == TYPE_CODE_PTR) - res_val = value_ptradd (arg2, arg1); + if (TYPE_CODE (ltype) == TYPE_CODE_PTR + && is_integral_type (rtype)) + res_val = value_ptradd (arg1, value_as_long (arg2)); + else if (TYPE_CODE (rtype) == TYPE_CODE_PTR + && is_integral_type (ltype)) + res_val = value_ptradd (arg2, value_as_long (arg1)); else res_val = value_binop (arg1, arg2, BINOP_ADD); } @@ -431,16 +433,14 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) CHECK_TYPEDEF (rtype); rtype = STRIP_REFERENCE (rtype); - if (TYPE_CODE (ltype) == TYPE_CODE_PTR) - { - if (TYPE_CODE (rtype) == TYPE_CODE_PTR) - /* A ptrdiff_t for the target would be preferable - here. */ - res_val = value_from_longest (builtin_type_pyint, - value_ptrdiff (arg1, arg2)); - else - res_val = value_ptrsub (arg1, arg2); - } + if (TYPE_CODE (ltype) == TYPE_CODE_PTR + && TYPE_CODE (rtype) == TYPE_CODE_PTR) + /* A ptrdiff_t for the target would be preferable here. */ + res_val = value_from_longest (builtin_type_pyint, + value_ptrdiff (arg1, arg2)); + else if (TYPE_CODE (ltype) == TYPE_CODE_PTR + && is_integral_type (rtype)) + res_val = value_ptradd (arg1, - value_as_long (arg2)); else res_val = value_binop (arg1, arg2, BINOP_SUB); } -- cgit v1.1