* eval.c (evaluate_subexp_standard): Fix type of result of mixed

integer/float division operations when EVAL_AVOID_SIDE_EFFECTS.
	* valops.c (value_one): New function.
	* value.h (value_one): Declare.

	Fix argument promotion for binary arithmetic ops for C.
	* valarith.c (unop_result_type): New fn.
	(binop_result_type): New fn.
	(value_binop): Move result type computation to binop_result_type.
	(value_pos, value_neg, value_complement): Move result type
	computation to unop_result_type.

	* gdb.base/whatis-exp.exp: Fix expected result of whatis x+y, x-y, x*y.
This commit is contained in:
Doug Evans
2008-02-04 00:23:05 +00:00
parent e44a2c9c3d
commit 301f0ecf99
7 changed files with 399 additions and 153 deletions

View File

@@ -471,6 +471,40 @@ value_zero (struct type *type, enum lval_type lv)
return val;
}
/* Create a value of numeric type TYPE that is one, and return it. */
struct value *
value_one (struct type *type, enum lval_type lv)
{
struct type *type1 = check_typedef (type);
struct value *val = NULL; /* avoid -Wall warning */
if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
{
struct value *int_one = value_from_longest (builtin_type_int, 1);
struct value *val;
gdb_byte v[16];
decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int));
val = value_from_decfloat (type, v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
{
val = value_from_double (type, (DOUBLEST) 1);
}
else if (is_integral_type (type1))
{
val = value_from_longest (type, (LONGEST) 1);
}
else
{
error (_("Not a numeric type."));
}
VALUE_LVAL (val) = lv;
return val;
}
/* Return a value with type TYPE located at ADDR.
Call value_at only if the data needs to be fetched immediately;