* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / eval.c
index 77ae90c4eb1823c3008867e368897c8195863a4f..971ad9a32d4abcbe2deb45adad11bd22a2cd2da6 100644 (file)
@@ -24,6 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "expression.h"
 #include "target.h"
 #include "frame.h"
+#include "language.h"  /* For CAST_IS_CONVERSION */
 
 /* Values of NOSIDE argument to eval_subexp.  */
 enum noside
@@ -542,6 +543,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
     case BINOP_MUL:
     case BINOP_DIV:
     case BINOP_REM:
+    case BINOP_MOD:
     case BINOP_LSH:
     case BINOP_RSH:
     case BINOP_BITWISE_AND:
@@ -555,7 +557,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
        return value_x_binop (arg1, arg2, op, OP_NULL);
       else
        if (noside == EVAL_AVOID_SIDE_EFFECTS
-           && (op == BINOP_DIV || op == BINOP_REM))
+           && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD))
          return value_zero (VALUE_TYPE (arg1), not_lval);
       else
        return value_binop (arg1, arg2, op);
@@ -1041,9 +1043,16 @@ evaluate_subexp_for_address (exp, pos, noside)
 }
 
 /* Evaluate like `evaluate_subexp' except coercing arrays to pointers.
-   When used in contexts where arrays will be coerced anyway,
-   this is equivalent to `evaluate_subexp'
-   but much faster because it avoids actually fetching array contents.  */
+   When used in contexts where arrays will be coerced anyway, this is
+   equivalent to `evaluate_subexp' but much faster because it avoids
+   actually fetching array contents.
+
+   Note that we currently only do the coercion for C expressions, where
+   arrays are zero based and the coercion is correct.  For other languages,
+   with nonzero based arrays, coercion loses.  Use CAST_IS_CONVERSION
+   to decide if coercion is appropriate.
+
+  */
 
 static value
 evaluate_subexp_with_coercion (exp, pos, noside)
@@ -1063,7 +1072,8 @@ evaluate_subexp_with_coercion (exp, pos, noside)
     {
     case OP_VAR_VALUE:
       var = exp->elts[pc + 1].symbol;
-      if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_ARRAY)
+      if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_ARRAY
+         && CAST_IS_CONVERSION)
        {
          (*pos) += 3;
          val = locate_var_value (var, (FRAME) 0);
This page took 0.024018 seconds and 4 git commands to generate.