summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-09-30 18:46:37 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-09-30 18:46:37 +0000
commit6b0d7253afe4a7978ace7558016a0e8d5c844e74 (patch)
tree18ca40946e6aae009ee70b338c48a0f728eedf85
parent9a044a8903fdfe53411787984379191d15373019 (diff)
downloadbinutils-gdb-6b0d7253afe4a7978ace7558016a0e8d5c844e74.tar.gz
* ada-lang.c (ada_evaluate_subexp) [UNOP_IND]: Remove strange
treatment of expect_type. Return the correct type when dereferencing an integer.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c30
2 files changed, 26 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6d33cbbe3cc..eb6adddf8c6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-30 Joel Brobecker <brobecker@adacore.com>
+
+ * ada-lang.c (ada_evaluate_subexp) [UNOP_IND]: Remove strange
+ treatment of expect_type. Return the correct type when dereferencing
+ an integer.
+
2008-09-30 Tom Tromey <tromey@redhat.com>
PR gdb/2484:
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c425c80d41f..02a20b4daa5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9103,9 +9103,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
return arg1;
case UNOP_IND:
- if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
- expect_type = TYPE_TARGET_TYPE (ada_check_typedef (expect_type));
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
+ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
type = ada_check_typedef (value_type (arg1));
@@ -9131,22 +9129,34 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
return value_zero (type, lval_memory);
}
else if (TYPE_CODE (type) == TYPE_CODE_INT)
- /* GDB allows dereferencing an int. */
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
- lval_memory);
+ {
+ /* GDB allows dereferencing an int. */
+ if (expect_type == NULL)
+ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ lval_memory);
+ else
+ {
+ expect_type =
+ to_static_fixed_type (ada_aligned_type (expect_type));
+ return value_zero (expect_type, lval_memory);
+ }
+ }
else
error (_("Attempt to take contents of a non-pointer value."));
}
arg1 = ada_coerce_ref (arg1); /* FIXME: What is this for?? */
type = ada_check_typedef (value_type (arg1));
+ if (TYPE_CODE (type) == TYPE_CODE_INT && expect_type != NULL)
+ /* GDB allows dereferencing an int. We give it the expected
+ type (which will be set in the case of a coercion or
+ qualification). */
+ return ada_value_ind (value_cast (lookup_pointer_type (expect_type),
+ arg1));
+
if (ada_is_array_descriptor_type (type))
/* GDB allows dereferencing GNAT array descriptors. */
return ada_coerce_to_simple_array (arg1);
- else if (TYPE_CODE (type) == TYPE_CODE_INT)
- /* GDB allows dereferencing an int. */
- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
- (CORE_ADDR) value_as_address (arg1));
else
return ada_value_ind (arg1);