aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-01-01 07:38:37 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-01-01 07:38:37 +0000
commitb7789565fa3afa8b4da2b2c26ac5670f5a95e2dd (patch)
treeaceecc952efb33820d56a87e98926ac61d33cf07
parent319e46745fc2267f605f6c75c664ae54a9693edf (diff)
downloadfsf-binutils-gdb-b7789565fa3afa8b4da2b2c26ac5670f5a95e2dd.zip
fsf-binutils-gdb-b7789565fa3afa8b4da2b2c26ac5670f5a95e2dd.tar.gz
fsf-binutils-gdb-b7789565fa3afa8b4da2b2c26ac5670f5a95e2dd.tar.bz2
* ada-lang.c (ada_evaluate_subexp, case BINOP_SUB): Add handling
of the case where the first argument is a reference. (ada_evaluate_subexp, case BINOP_ADD): Likewise.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c16
2 files changed, 20 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 41617bc..73d984e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2008-01-01 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.c (ada_evaluate_subexp, case BINOP_SUB): Add handling
+ of the case where the first argument is a reference.
+ (ada_evaluate_subexp, case BINOP_ADD): Likewise.
+
+2008-01-01 Joel Brobecker <brobecker@adacore.com>
+
Implement support for Ada interface types.
* ada-lang.c (ada_is_dispatch_table_ptr_type): New function.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9493506..04a5463 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8130,7 +8130,13 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
error (_("Operands of fixed-point addition must have the same type"));
- return value_cast (value_type (arg1), value_add (arg1, arg2));
+ /* Do the addition, and cast the result to the type of the first
+ argument. We cannot cast the result to a reference type, so if
+ ARG1 is a reference type, find its underlying type. */
+ type = value_type (arg1);
+ while (TYPE_CODE (type) == TYPE_CODE_REF)
+ type = TYPE_TARGET_TYPE (type);
+ return value_cast (type, value_add (arg1, arg2));
case BINOP_SUB:
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -8141,7 +8147,13 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
error (_("Operands of fixed-point subtraction must have the same type"));
- return value_cast (value_type (arg1), value_sub (arg1, arg2));
+ /* Do the substraction, and cast the result to the type of the first
+ argument. We cannot cast the result to a reference type, so if
+ ARG1 is a reference type, find its underlying type. */
+ type = value_type (arg1);
+ while (TYPE_CODE (type) == TYPE_CODE_REF)
+ type = TYPE_TARGET_TYPE (type);
+ return value_cast (type, value_sub (arg1, arg2));
case BINOP_MUL:
case BINOP_DIV: