From 11b8962251b584202478b1d3d0d2413f6d335dd4 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Dec 1998 15:32:49 +0000 Subject: [PATCH] gjavah.c (print_field_info): If value to print is the smallest value of its size... * 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 | 6 ++++++ gcc/java/gjavah.c | 47 +++++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index f81222fb3db..a2893099104 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +1998-12-14 Tom Tromey + + * 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 * gjavah.c (decompile_method): Decompile `return null'. diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 8fa0d0eb738..af9a6c78646 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -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: { -- 2.30.2