Java warning patches

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Fri Oct 20 19:35:00 GMT 2000


The following patch eliminates ~40 warnings in the java directory.

About 35 of the warnings are "value computed is not used" from
verify.c.  (You'll only see these in a 3-stage from recent CVS.)

The rest of the warnings are "function defined but not used" from
jcf-reader.c.  That file, jcf-reader.c, is included in three others.
Only one of the three files (gjavah.c) makes use of peek_attribute and
skip_attribute.  So I arrange to define these functions only when we
see a macro that comes from gjavah.c.  I picked an arbitrary one,
METHOD_IS_FINAL, if you'd like me to pick another let me know.

Bootstrapped on solaris2.7, okay to install?

		--Kaveh



2000-10-16  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* jcf-reader.c (peek_attribute, skip_attribute): Only define
	when used.

	* parse.h (yyerror): If JC1_LITE, mark with ATTRIBUTE_NORETURN.

	* verify.c (CHECK_PC_IN_RANGE): Cast result of stmt-expr to void.
	
diff -rup orig/egcs-CVS20001019/gcc/java/jcf-reader.c egcs-CVS20001019/gcc/java/jcf-reader.c
--- orig/egcs-CVS20001019/gcc/java/jcf-reader.c	Tue Aug  8 10:30:23 2000
+++ egcs-CVS20001019/gcc/java/jcf-reader.c	Fri Oct 20 11:28:32 2000
@@ -27,8 +27,10 @@ The Free Software Foundation is independ
 #include "zipfile.h"
 
 static int get_attribute PARAMS ((JCF *));
+#ifdef METHOD_IS_FINAL /* These are only used in gjavah.c.  */
 static int peek_attribute PARAMS ((JCF *, int, const char *, int));
 static void skip_attribute PARAMS ((JCF *, int));
+#endif
 static int jcf_parse_preamble PARAMS ((JCF *));
 static int jcf_parse_constant_pool PARAMS ((JCF *));
 static void jcf_parse_class PARAMS ((JCF *));
@@ -42,6 +44,7 @@ static int jcf_parse_final_attributes PA
    otherwise. JCF is restored to its initial position before
    returning.  */
 
+#ifdef METHOD_IS_FINAL /* These are only used in gjavah.c.  */
 static int
 peek_attribute (jcf, attribute_number, peeked_name, peeked_name_length)
       JCF *jcf;
@@ -94,6 +97,7 @@ skip_attribute (jcf, number_of_attribute
       JCF_SKIP (jcf, JCF_readu4 (jcf));
     }
 }
+#endif
 
 static int
 DEFUN(get_attribute, (jcf),
diff -rup orig/egcs-CVS20001019/gcc/java/parse.h egcs-CVS20001019/gcc/java/parse.h
--- orig/egcs-CVS20001019/gcc/java/parse.h	Fri Oct 13 10:07:39 2000
+++ egcs-CVS20001019/gcc/java/parse.h	Fri Oct 20 11:28:32 2000
@@ -940,6 +940,10 @@ extern void java_parser_context_save_glo
 extern void java_parser_context_restore_global PARAMS ((void));
 int yyparse PARAMS ((void));
 extern int java_parse PARAMS ((void));
-void yyerror PARAMS ((const char *));
+extern void yyerror PARAMS ((const char *))
+#ifdef JC1_LITE
+ATTRIBUTE_NORETURN
+#endif
+;
 extern void java_expand_classes PARAMS ((void));
 #endif
diff -rup orig/egcs-CVS20001019/gcc/java/verify.c egcs-CVS20001019/gcc/java/verify.c
--- orig/egcs-CVS20001019/gcc/java/verify.c	Wed Sep 13 10:35:51 2000
+++ egcs-CVS20001019/gcc/java/verify.c	Fri Oct 20 16:22:03 2000
@@ -353,7 +353,7 @@ start_pc_cmp (xp, yp)
              goto verify_error; } while (0)
 
 #ifdef __GNUC__
-#define CHECK_PC_IN_RANGE(PC) ({if (PC < 0 || PC > length) goto bad_pc; 1;})
+#define CHECK_PC_IN_RANGE(PC) ({if (PC < 0 || PC > length) goto bad_pc; (void)1;})
 #else
 #define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > length ? \
   (fatal("Bad byte codes.\n"), 0) : 1)


More information about the Gcc-patches mailing list