diff options
author | Doug Evans <dje@google.com> | 2008-02-04 00:23:05 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2008-02-04 00:23:05 +0000 |
commit | 55dcce129c60fa230b81b758d4dcc8ab8fd9cdb6 (patch) | |
tree | ad74e955a3db718a3d1d7dd60ee7a9cb18ded2fa /gdb/valops.c | |
parent | abc10851528ab324b577c776edbc05388b7f349f (diff) | |
download | gdb-55dcce129c60fa230b81b758d4dcc8ab8fd9cdb6.tar.gz |
* 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.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index d4a0a9a27d4..69ebb15f821 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -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; |