expr.c (build_known_method_ref): Use method's context to find method table index.
authorTom Tromey <tromey@redhat.com>
Thu, 23 Jan 2003 21:19:50 +0000 (21:19 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 23 Jan 2003 21:19:50 +0000 (21:19 +0000)
* expr.c (build_known_method_ref): Use method's context to find
method table index.

From-SVN: r61670

gcc/java/ChangeLog
gcc/java/expr.c

index 092d5bdc0d6fb3e7ad7b363c29d545920f8183a9..3050610a29169decc790084fe9e5f4fb254ac3da 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-23  Tom Tromey  <tromey@redhat.com>
+
+       * expr.c (build_known_method_ref): Use method's context to find
+       method table index.
+
 2003-01-23  Tom Tromey  <tromey@redhat.com>
 
        * constants.c (set_constant_entry): Allocated cleared memory.
index bf1f41b541405176e62daef9d93b187a777135c5..5ce92e00376d703550105cc21fc43e647a70f101 100644 (file)
@@ -1748,13 +1748,16 @@ build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED,
 
         SELF_TYPE->methods[METHOD_INDEX].ncode
 
-        This is guaranteed to work (assuming SELF_TYPE has
-        been initialized), since if the method is not compiled yet,
-        its ncode points to a trampoline that forces compilation. */
+      */
 
       int method_index = 0;
-      tree meth;
-      tree ref = build_class_ref (self_type);
+      tree meth, ref;
+
+      /* The method might actually be declared in some superclass, so
+        we have to use its class context, not the caller's notion of
+        where the method is.  */
+      self_type = DECL_CONTEXT (method);
+      ref = build_class_ref (self_type);
       ref = build1 (INDIRECT_REF, class_type_node, ref);
       if (ncode_ident == NULL_TREE)
        ncode_ident = get_identifier ("ncode");