diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2005-03-08 14:35:20 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@codesourcery.com> | 2005-03-08 14:35:20 +0000 |
commit | 36e9969cac95317f057b47509cf63271bccd98b0 (patch) | |
tree | b8c229973ba4500194f9b95686edd5d45fef1e89 /gdb/valarith.c | |
parent | 3de11b2ef2c380882c4dcf3fa980b9817d229b04 (diff) | |
download | gdb-36e9969cac95317f057b47509cf63271bccd98b0.zip gdb-36e9969cac95317f057b47509cf63271bccd98b0.tar.gz gdb-36e9969cac95317f057b47509cf63271bccd98b0.tar.bz2 |
* ax-gdb.c (gen_expr): Add UNOP_PLUS case.
* c-exp.y (exp): Add unary plus.
* eval.c (evaluate_subexp_standard): Add UNOP_PLUS case.
* valarith.c (value_x_unop): Add UNOP_PLUS case.
(value_pos): New.
* value.h (value_pos): Declare.
* gdb.cp/userdef.cc (A1::operator+): New unary plus.
(A2): New class.
(main): Test operator+.
* gdb.cp/userdef.exp: Test unary plus. Use A2::operator+ for
breakpoint test.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 4322c44..7908900 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -560,6 +560,9 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) case UNOP_NEG: strcpy (ptr, "-"); break; + case UNOP_PLUS: + strcpy (ptr, "+"); + break; case UNOP_IND: strcpy (ptr, "*"); break; @@ -1313,7 +1316,34 @@ value_less (struct value *arg1, struct value *arg2) } } -/* The unary operators - and ~. Both free the argument ARG1. */ +/* The unary operators +, - and ~. They free the argument ARG1. */ + +struct value * +value_pos (struct value *arg1) +{ + struct type *type; + + arg1 = coerce_ref (arg1); + + type = check_typedef (value_type (arg1)); + + if (TYPE_CODE (type) == TYPE_CODE_FLT) + return value_from_double (type, value_as_double (arg1)); + else if (is_integral_type (type)) + { + /* Perform integral promotion for ANSI C/C++. FIXME: What about + FORTRAN and (the deleted) chill ? */ + if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int)) + type = builtin_type_int; + + return value_from_longest (type, value_as_long (arg1)); + } + else + { + error ("Argument to positive operation not a number."); + return 0; /* For lint -- never reached */ + } +} struct value * value_neg (struct value *arg1) |