Original patch posted as part of Nios II patches:
http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01087.html

This patch is to allow hexadecimal numbers to be used in option
arguments, e.g. -falign-loops=0x10 can now be used as equivalent to
-falign-loops=16.

Joseph, the patch has been modified to use IXDIGIT to check the argument
string first, as you suggested in the last submission. Is this okay for
trunk?

Thanks,
Chung-Lin

2013-07-14  Chung-Lin Tang  <clt...@codesourcery.com>

        * opts-common.c (integral_argument): Add support for hexadecimal
        command option integer arguments. Update comments.
Index: opts-common.c
===================================================================
--- opts-common.c	(revision 200946)
+++ opts-common.c	(working copy)
@@ -147,7 +147,7 @@ find_opt (const char *input, unsigned int lang_mas
   return match_wrong_lang;
 }
 
-/* If ARG is a non-negative integer made up solely of digits, return its
+/* If ARG is a non-negative decimal or hexadecimal integer, return its
    value, otherwise return -1.  */
 
 int
@@ -161,6 +161,17 @@ integral_argument (const char *arg)
   if (*p == '\0')
     return atoi (arg);
 
+  /* It wasn't a decimal number - try hexadecimal.  */
+  if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X'))
+    {
+      p = arg + 2;
+      while (*p && ISXDIGIT (*p))
+	p++;
+
+      if (*p == '\0')
+	return strtol (arg, NULL, 16);
+    }
+
   return -1;
 }
 

Reply via email to