diff options
author | Jan Beulich <jbeulich@novell.com> | 2009-04-16 08:52:27 +0000 |
---|---|---|
committer | Jan Beulich <jbeulich@novell.com> | 2009-04-16 08:52:27 +0000 |
commit | d85733c8e2e51ba2159d27fe10d36b0eba98884d (patch) | |
tree | 2fee7b99df3f1cf26b2d5b292640824a38ab199e /gas/expr.c | |
parent | 3f904b169712db815150b4d032ca2bfff79b2b4a (diff) | |
download | gdb-d85733c8e2e51ba2159d27fe10d36b0eba98884d.zip gdb-d85733c8e2e51ba2159d27fe10d36b0eba98884d.tar.gz gdb-d85733c8e2e51ba2159d27fe10d36b0eba98884d.tar.bz2 |
gas/
2009-04-16 Jan Beulich <jbeulich@novell.com>
* expr.c: Include limits.h if available, and #define CHAR_BITS
otherwise.
(expr): Check range of shift count when evaluating a constant
expression.
Diffstat (limited to 'gas/expr.c')
-rw-r--r-- | gas/expr.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -31,6 +31,13 @@ #include "safe-ctype.h" #include "obstack.h" +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + static void floating_constant (expressionS * expressionP); static valueT generic_bignum_to_int32 (void); #ifdef BFD64 @@ -1779,6 +1786,14 @@ expr (int rankarg, /* Larger # is higher rank. */ as_warn (_("division by zero")); v = 1; } + if ((valueT) v >= sizeof(valueT) * CHAR_BIT + && (op_left == O_left_shift || op_left == O_right_shift)) + { + as_warn_value_out_of_range (_("shift count"), v, 0, + sizeof(valueT) * CHAR_BIT - 1, + NULL, 0); + resultP->X_add_number = v = 0; + } switch (op_left) { default: abort (); |