OSDN Git Service

gas/
authorjbeulich <jbeulich>
Thu, 16 Apr 2009 08:52:26 +0000 (08:52 +0000)
committerjbeulich <jbeulich>
Thu, 16 Apr 2009 08:52:26 +0000 (08:52 +0000)
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.

gas/ChangeLog
gas/expr.c

index 910f8b0..b837c17 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2009-04-15  Jan Beulich  <jbeulich@novell.com>
 
        * config/tc-i386.c (process_operands): Print operands in
index 285b438..39f21ef 100644 (file)
 #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 ();