aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1993-01-03 22:24:21 +0000
committerFred Fish <fnf@specifix.com>1993-01-03 22:24:21 +0000
commitfb6e675f95e39ecf9f8664861b64243001fc0a11 (patch)
tree67fb6eb6769b56a53cc4c8fbb9f37436a35d8791 /gdb/eval.c
parent191395156c25bce7915660307c78708269ff6c0f (diff)
downloadgdb-fb6e675f95e39ecf9f8664861b64243001fc0a11.zip
gdb-fb6e675f95e39ecf9f8664861b64243001fc0a11.tar.gz
gdb-fb6e675f95e39ecf9f8664861b64243001fc0a11.tar.bz2
* eval.c (language.h): Include.
* eval.c (evaluate_subexp_with_coercion): Only coerce arrays to pointer types when the current language is C. It loses for other languages when the lower index bound is nonzero. * valarith.c (value_subscript): Take array lower bounds into account when performing subscripting operations. * valops.c (value_coerce_array): Add comment describing why arrays with nonzero lower bounds are dealt with in value_subscript, rather than in value_coerce_array.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 77ae90c..fef404a 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -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
@@ -1041,9 +1042,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 +1071,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);