cp-demangle.c (d_substitution): Correct overflow check to avoid -fstrict-overflow...
authorIan Lance Taylor <iant@google.com>
Mon, 31 Mar 2008 17:38:38 +0000 (17:38 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 31 Mar 2008 17:38:38 +0000 (17:38 +0000)
* cp-demangle.c (d_substitution): Correct overflow check to avoid
-fstrict-overflow optimizations.

From-SVN: r133761

libiberty/ChangeLog
libiberty/cp-demangle.c

index c85691c40e1f2de3c4fa741917f64b52034c86cc..0e8424d56e8c6c9bb8b72a5d6a45ce44dd607937 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-31  Ian Lance Taylor  <iant@google.com>
+
+       * cp-demangle.c (d_substitution): Correct overflow check to avoid
+       -fstrict-overflow optimizations.
+
 2008-03-27  Paolo Bonzini  <bonzini@gnu.org>
 
        * configure.ac (frags): Don't set, use frag instead.
index edcfedca7a59f338a4a44afd3d298410a7f1ee85..71a28ab539b39c4f432201f629d9b6292084f31c 100644 (file)
@@ -2681,21 +2681,24 @@ d_substitution (struct d_info *di, int prefix)
   c = d_next_char (di);
   if (c == '_' || IS_DIGIT (c) || IS_UPPER (c))
     {
-      int id;
+      unsigned int id;
 
       id = 0;
       if (c != '_')
        {
          do
            {
+             unsigned int new_id;
+
              if (IS_DIGIT (c))
-               id = id * 36 + c - '0';
+               new_id = id * 36 + c - '0';
              else if (IS_UPPER (c))
-               id = id * 36 + c - 'A' + 10;
+               new_id = id * 36 + c - 'A' + 10;
              else
                return NULL;
-             if (id < 0)
+             if (new_id < id)
                return NULL;
+             id = new_id;
              c = d_next_char (di);
            }
          while (c != '_');
@@ -2703,7 +2706,7 @@ d_substitution (struct d_info *di, int prefix)
          ++id;
        }
 
-      if (id >= di->next_sub)
+      if (id >= (unsigned int) di->next_sub)
        return NULL;
 
       ++di->did_subs;