* ada-lang.c (ada_evaluate_subexp, case BINOP_SUB): Add handling
authorJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 07:38:37 +0000 (07:38 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 07:38:37 +0000 (07:38 +0000)
        of the case where the first argument is a reference.
        (ada_evaluate_subexp, case BINOP_ADD): Likewise.

gdb/ChangeLog
gdb/ada-lang.c

index 41617bca52c6c048e0ffbd9e4e16c733461f2d46..73d984ed654484de425f9303351954b78376b210 100644 (file)
@@ -1,3 +1,9 @@
+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.
index 949350615fb67b8f47b7c63ce6d2981af40a5b27..04a54632119b844cebab47685f2295afde1b9102 100644 (file)
@@ -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:
This page took 0.031059 seconds and 4 git commands to generate.