This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: -Wunreachable-bytecode
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 15 Jun 2002 13:14:30 -0600
- Subject: Patch: -Wunreachable-bytecode
- Reply-to: tromey at redhat dot com
This patch adds a new -Wunreachable-bytecode warning to gcj. I added
this because we want to suppress these warnings in the test suite, and
this seemed like the most straightforward approach to doing so.
Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* gcj.texi (Warnings): Document -Wunreachable-bytecode.
* expr.c (expand_byte_code): Use flag_unreachable_bytecode.
* java-tree.h (flag_unreachable_bytecode): Declare.
* lang.c (lang_W_options) [unreachable-bytecode]: Added.
(flag_unreachable_bytecode): New global.
(java_decode_option): Set flag_unreachable_bytecode with -Wall.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.147
diff -u -r1.147 expr.c
--- expr.c 4 Jun 2002 20:31:54 -0000 1.147
+++ expr.c 15 Jun 2002 19:00:02 -0000
@@ -1,5 +1,5 @@
/* Process expressions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -2852,8 +2852,9 @@
if (dead_code_index != -1)
{
/* We've just reached the end of a region of dead code. */
- warning ("unreachable bytecode from %d to before %d",
- dead_code_index, PC);
+ if (flag_unreachable_bytecode)
+ warning ("unreachable bytecode from %d to before %d",
+ dead_code_index, PC);
dead_code_index = -1;
}
}
@@ -2889,8 +2890,9 @@
if (dead_code_index != -1)
{
/* We've just reached the end of a region of dead code. */
- warning ("unreachable bytecode from %d to the end of the method",
- dead_code_index);
+ if (flag_unreachable_bytecode)
+ warning ("unreachable bytecode from %d to the end of the method",
+ dead_code_index);
}
}
Index: gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.31
diff -u -r1.31 gcj.texi
--- gcj.texi 4 Jun 2002 22:00:42 -0000 1.31
+++ gcj.texi 15 Jun 2002 19:00:04 -0000
@@ -351,12 +351,16 @@
newer than its matching class file. By default @command{gcj} will warn
about this.
+@item -Wunreachable-bytecode
+This warns about unreachable bytecode in the compiled @file{.class}
+files. This warning is enabled by default.
+
@item -Wunused
This is the same as @command{gcc}'s @code{-Wunused}.
@item -Wall
This is the same as @code{-Wredundant-modifiers -Wextraneous-semicolon
--Wunused}.
+-Wunused -Wunreachable-bytecode}.
@end table
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.153
diff -u -r1.153 java-tree.h
--- java-tree.h 11 Jun 2002 17:31:10 -0000 1.153
+++ java-tree.h 15 Jun 2002 19:00:06 -0000
@@ -169,6 +169,10 @@
extern int flag_extraneous_semicolon;
+/* When non zero, report unreachable bytecode. */
+
+extern int flag_unreachable_bytecode;
+
/* When non zero, always check for a non gcj generated classes archive. */
extern int flag_force_classes_archive_check;
Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.103
diff -u -r1.103 lang.c
--- lang.c 10 Jun 2002 05:11:42 -0000 1.103
+++ lang.c 15 Jun 2002 19:00:06 -0000
@@ -1,5 +1,5 @@
/* Java(TM) language-specific utility routines.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -155,6 +155,9 @@
/* When non zero, report the now deprecated empty statements. */
int flag_extraneous_semicolon;
+/* When non zero, report unreachable bytecode. */
+int flag_unreachable_bytecode = 1;
+
/* When non zero, always check for a non gcj generated classes archive. */
int flag_force_classes_archive_check;
@@ -204,7 +207,8 @@
{
{ "redundant-modifiers", &flag_redundant, 1 },
{ "extraneous-semicolon", &flag_extraneous_semicolon, 1 },
- { "out-of-date", &flag_newer, 1 }
+ { "out-of-date", &flag_newer, 1 },
+ { "unreachable-bytecode", &flag_unreachable_bytecode, 1 }
};
JCF *current_jcf;
@@ -422,6 +426,7 @@
flag_wall = 1;
flag_redundant = 1;
flag_extraneous_semicolon = 1;
+ flag_unreachable_bytecode = 1;
/* When -Wall given, enable -Wunused. We do this because the C
compiler does it, and people expect it. */
set_Wunused (1);