bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/6994] Support L/LL suffix in integer constants


From: hjl dot tools at gmail dot com
Subject: [Bug gas/6994] Support L/LL suffix in integer constants
Date: 29 Oct 2008 07:02:44 -0000

------- Additional Comments From hjl dot tools at gmail dot com  2008-10-29 
07:02 -------
Does this patch make sense?

--- ./expr.c.ll 2007-10-30 11:48:37.000000000 -0700
+++ ./expr.c    2008-10-28 23:43:00.000000000 -0700
@@ -241,6 +241,12 @@ generic_bignum_to_int64 (void)
 }
 #endif

+struct suffix
+{
+  const char *suffix;
+  int len;
+};
+
 static void
 integer_constant (int radix, expressionS *expressionP)
 {
@@ -253,8 +259,30 @@ integer_constant (int radix, expressionS
   int too_many_digits = 0;     /* If we see >= this number of.  */
   char *name;          /* Points to name of symbol.  */
   symbolS *symbolP;    /* Points to symbol.  */
-
   int small;                   /* True if fits in 32 bits.  */
+  static const struct suffix long_suffix[] =
+    {
+     { STRING_COMMA_LEN ("L") },
+     { STRING_COMMA_LEN ("UL") },
+     { NULL, 0 }
+    };
+  static const struct suffix long_long_suffix[] =
+    {
+     { STRING_COMMA_LEN ("L") },
+     { STRING_COMMA_LEN ("UL") },
+     { STRING_COMMA_LEN ("LL") },
+     { STRING_COMMA_LEN ("ULL") },
+     { NULL, 0 }
+    };
+  const struct suffix *valid_suffix;
+
+  if (sizeof (valueT) == sizeof (long long))
+    valid_suffix = long_long_suffix;
+  else
+  if (sizeof (valueT) == sizeof (long))
+    valid_suffix = long_suffix;
+  else
+    valid_suffix = NULL;

   /* May be bignum, or may fit in 32 bits.  */
   /* Most numbers fit into 32 bits, and we want this case to be fast.
@@ -586,6 +614,16 @@ integer_constant (int radix, expressionS
          expressionP->X_op = O_constant;
          expressionP->X_add_number = number;
          input_line_pointer--; /* Restore following character.  */
+
+         /* Allow L/LL suffixes.  */
+         if (*input_line_pointer && valid_suffix)
+           for (; valid_suffix->suffix; valid_suffix++)
+             if (strcasecmp (valid_suffix->suffix,
+                             input_line_pointer) == 0)
+               {
+                 input_line_pointer += valid_suffix->len;
+                 break;
+               }
        }                       /* Really just a number.  */
     }
   else

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=6994

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]