This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Remove warning about unreachable bytecodes
- From: Tom Tromey <tromey at redhat dot com>
- To: GCC libjava patches <java-patches at gcc dot gnu dot org>
- Date: 21 Oct 2003 12:10:45 -0600
- Subject: Re: Remove warning about unreachable bytecodes
- References: <1066724241.22241.11.camel@famine><62F916F1-03A5-11D8-8833-003065F97F7C@mckinlay.net.nz><3F950A44.50200@bothner.com>
- Reply-to: tromey at redhat dot com
Bryce> I vote to remove it, or perhaps we can make it only appear with -Wall.
Andrew> I agree. It seems that these compilers will not cease to produce
Andrew> unreachable bytecode.
Per> Having it be controlled by -Wall or perhaps -Wextra seems a godd idea.
Sounds like consensus.
Here's my old patch as a starting point.
Do we want a new option?
Do we want if off by default?
Tom
Index: gcc/java/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: gcc/java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.147
diff -u -r1.147 expr.c
--- gcc/java/expr.c 4 Jun 2002 20:31:54 -0000 1.147
+++ gcc/java/expr.c 17 Jun 2002 03:57:36 -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: gcc/java/gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.31
diff -u -r1.31 gcj.texi
--- gcc/java/gcj.texi 4 Jun 2002 22:00:42 -0000 1.31
+++ gcc/java/gcj.texi 17 Jun 2002 03:57:38 -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: gcc/java/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
--- gcc/java/java-tree.h 11 Jun 2002 17:31:10 -0000 1.153
+++ gcc/java/java-tree.h 17 Jun 2002 03:57:40 -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: gcc/java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.103
diff -u -r1.103 lang.c
--- gcc/java/lang.c 10 Jun 2002 05:11:42 -0000 1.103
+++ gcc/java/lang.c 17 Jun 2002 03:57:40 -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);
Index: libjava/testsuite/ChangeLog
from Tom Tromey <tromey@redhat.com>
* lib/libjava.exp (find_javac): Use -Wno-unreachable-bytecode.
Index: libjava/testsuite/lib/libjava.exp
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/lib/libjava.exp,v
retrieving revision 1.42
diff -u -r1.42 libjava.exp
--- libjava/testsuite/lib/libjava.exp 13 Jun 2002 17:34:47 -0000 1.42
+++ libjava/testsuite/lib/libjava.exp 17 Jun 2002 03:57:42 -0000
@@ -71,7 +71,10 @@
if {[info exists env(SUN_JAVAC)]} {
set SUN_JAVAC $env(SUN_JAVAC)
} else {
- set SUN_JAVAC "$GCJ_UNDER_TEST -C"
+ # Use -Wno-unreachable-bytecode because we don't currently
+ # care about such warnings, and they cause dejagnu to
+ # think we've hit an error.
+ set SUN_JAVAC "$GCJ_UNDER_TEST -C -Wno-unreachable-bytecode"
}
}
return $SUN_JAVAC