gjavah.c (print_field_info): If value to print is the smallest value of its size...
authorTom Tromey <tromey@cygnus.com>
Mon, 14 Dec 1998 15:32:49 +0000 (15:32 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 14 Dec 1998 15:32:49 +0000 (15:32 +0000)
* gjavah.c (print_field_info): If value to print is the smallest
value of its size, then print as hex to avoid later warnings from
C++ compiler.

From-SVN: r24313

gcc/java/ChangeLog
gcc/java/gjavah.c

index f81222fb3dbde5178cc6113e1554428e6a46186e..a289309910473b642bea889c32156b1e85277c83 100644 (file)
@@ -1,3 +1,9 @@
+1998-12-14  Tom Tromey  <tromey@cygnus.com>
+
+       * gjavah.c (print_field_info): If value to print is the smallest
+       value of its size, then print as hex to avoid later warnings from
+       C++ compiler.
+
 1998-12-14  Tom Tromey  <tromey@cygnus.com>
 
        * gjavah.c (decompile_method): Decompile `return null'.
index 8fa0d0eb738241b7267253bf773836020594b50d..af9a6c78646d7afb49058fe4368d8eedf43784c4 100644 (file)
@@ -299,27 +299,48 @@ DEFUN(print_field_info, (stream, jcf, name_index, sig_index, flags),
     {
       if (current_field_value > 0)
        {
-         jlong num;
          char buffer[25];
 
          generate_access (stream, flags);
          switch (JPOOL_TAG (jcf, current_field_value))
            {
            case CONSTANT_Integer:
-             fputs ("  static const jint ", out);
-             print_name (out, jcf, name_index);
-             fputs (" = ", out);
-             num = JPOOL_INT (jcf, current_field_value);
-             format_int (buffer, num, 10);
-             fprintf (out, "%sL;\n", buffer);
+             {
+               jint num;
+               fputs ("  static const jint ", out);
+               print_name (out, jcf, name_index);
+               fputs (" = ", out);
+               num = JPOOL_INT (jcf, current_field_value);
+               /* We single out the most negative number to print in
+                  hex.  That avoids later warnings from g++.  */
+               if (num == 0x80000000)
+                 {
+                   strcpy (buffer, "0x");
+                   format_uint (buffer + 2, (jlong) (uint32) num, 16);
+                 }
+               else
+                 format_int (buffer, (jlong) num, 10);
+               fprintf (out, "%sL;\n", buffer);
+             }
              break;
            case CONSTANT_Long:
-             fputs ("  static const jlong ", out);
-             print_name (out, jcf, name_index);
-             fputs (" = ", out);
-             num = JPOOL_LONG (jcf, current_field_value);
-             format_int (buffer, num, 10);
-             fprintf (out, "%sLL;\n", buffer);
+             {
+               jlong num;
+               fputs ("  static const jlong ", out);
+               print_name (out, jcf, name_index);
+               fputs (" = ", out);
+               num = JPOOL_LONG (jcf, current_field_value);
+               /* We single out the most negative number to print in
+                  hex.  That avoids later warnings from g++.  */
+               if (num == 0x8000000000000000LL)
+                 {
+                   strcpy (buffer, "0x");
+                   format_uint (buffer + 2, num, 16);
+                 }
+               else
+                 format_int (buffer, num, 10);
+               fprintf (out, "%sLL;\n", buffer);
+             }
              break;
            case CONSTANT_Float:
              {