This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: abort if interface call made on non-interface method
- 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: 21 Jan 2003 11:57:59 -0700
- Subject: Patch: abort if interface call made on non-interface method
- Reply-to: tromey at redhat dot com
This patch just adds a new abort() to gcc. It is a sanity check
against a problem I found last night.
In an unusual situation we can call build_invokeinterface with a
method whose context is Object, not an interface. This results in the
generation of incorrect code.
I think it makes more sense for us to detect this situation and crash.
I have a simple test case which I'll check in later on; I'm planning
to write a patch for the actual bug first.
Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* expr.c (build_invokeinterface): Abort if method's context is not
an interface.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.160
diff -u -r1.160 expr.c
--- expr.c 18 Jan 2003 22:15:51 -0000 1.160
+++ expr.c 21 Jan 2003 18:56:50 -0000
@@ -1901,15 +1901,16 @@
abstract nor static. */
if (class_ident == NULL_TREE)
- {
- class_ident = get_identifier ("class");
- }
+ class_ident = get_identifier ("class");
- dtable = build_java_indirect_ref (dtable_type, dtable, flag_check_references);
+ dtable = build_java_indirect_ref (dtable_type, dtable,
+ flag_check_references);
dtable = build (COMPONENT_REF, class_ptr_type, dtable,
lookup_field (&dtable_type, class_ident));
interface = DECL_CONTEXT (method);
+ if (! CLASS_INTERFACE (TYPE_NAME (interface)))
+ abort ();
layout_class_methods (interface);
if (flag_indirect_dispatch)