This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: avoid warning in more cases
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 18 Jan 2005 19:05:48 -0700
- Subject: [gcjx] Patch: FYI: avoid warning in more cases
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
The "extends Object" warning makes no sense in a few other cases.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/class.cc (do_resolve_classes): Don't emit 'extends Object'
warning for wildcards, type variables, or parameterized classes.
Index: model/class.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/class.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 class.cc
--- model/class.cc 19 Jan 2005 02:08:13 -0000 1.1.2.2
+++ model/class.cc 19 Jan 2005 02:09:54 -0000
@@ -1097,12 +1097,17 @@
superclass->resolve_classes (scope);
// If there was an explicit 'extends' clause, and this class
// isn't an array (we supply the extends clause for arrays) and
- // not anonymous (new Object() { } is just fine), then warn if
- // we are extending Object, as that is redundant. Don't bother
- // warning if the class came from a .class file -- those are
- // always completely explicit.
+ // not anonymous (new Object() { } is just fine), and not a
+ // wildcard, and not a type variable, and not a class instance
+ // (we would emit the warning when handling the parent class)
+ // then warn if we are extending Object, as that is redundant.
+ // Don't bother warning if the class came from a .class file --
+ // those are always completely explicit.
if (! was_null && ! array_p () && ! from_class
- && ! anonymous && superclass->type () == obj
+ && ! anonymous && superclass->type () == obj
+ && dynamic_cast<model_wildcard *> (this) == NULL
+ && ! type_variable_p ()
+ && ! parameterized_p ()
&& scope->warn_unneeded_extends ())
std::cerr << warn (global->get_compiler ()->warn_unneeded_extends (),
"explicit %<extends java.lang.Object%>");