public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Tested compiler PR patches
  2000-04-01  0:00 Tested compiler PR patches Bryce McKinlay
@ 2000-04-01  0:00 ` Alexandre Petit-Bianco
  2000-04-01  0:00   ` Alexandre Petit-Bianco
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Petit-Bianco @ 2000-04-01  0:00 UTC (permalink / raw)
  To: java-discuss, Bryce McKinlay

Bryce McKinlay writes:

> All of these PRs seem to be solved and there were no obvious
> problems or regressions caused by the patches.

Thanks a lot!

> I think they are good to be checked in, although I might have a
> closer look at 108 tommorrow...

I need to re-work on 108 to incorporate the fix described here:

  http://gcc.gnu.org/ml/gcc-patches/1999-12/msg00539.html

I'll run my own set of non regression and if the results aren't too
bad, then your new interface dispatch scheme will be good to go,
eventually.

./A

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Tested compiler PR patches
@ 2000-04-01  0:00 Bryce McKinlay
  2000-04-01  0:00 ` Alexandre Petit-Bianco
  0 siblings, 1 reply; 3+ messages in thread
From: Bryce McKinlay @ 2000-04-01  0:00 UTC (permalink / raw)
  To: apbianco; +Cc: java-discuss

Alex,

I installed your patches for the following PRs into my local tree,
rebuilt libgcj, ran the testsuite, checked that each of the PR test
cases was fixed, and rebuilt my own projects using the patched compiler.
All of these PRs seem to be solved and there were no obvious problems or
regressions caused by the patches. I think they are good to be checked
in, although I might have a closer look at 108 tommorrow...

regards

  [ bryce ]

gcj/80: Source Parser: failure to compile qualified references to static
fields and methods
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=80&database=java

gcj/145: gcj doesn't search non listed packages.
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=145&database=java

(note that PRs 80 and 145 are actually the same bug)

gcj/83: Failure to compile try/finally?
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=83&database=java

gcj/94: compiler allows assignment to interface constants
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=94&database=java

gcj/102: crashes when compiling try block from java source
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=102&database=java

gcj/107: Bad array or type conversion bug when compiling bytecode
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=107&database=java

gcj/108: Compiler doesn't check access modifiers on interface
implementations
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=108&database=java




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tested compiler PR patches
  2000-04-01  0:00 ` Alexandre Petit-Bianco
@ 2000-04-01  0:00   ` Alexandre Petit-Bianco
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Petit-Bianco @ 2000-04-01  0:00 UTC (permalink / raw)
  To: java-discuss, Bryce McKinlay

Alexandre Petit-Bianco writes:
> I need to re-work on 108 to incorporate the fix described here:
> 
>   http://gcc.gnu.org/ml/gcc-patches/1999-12/msg00539.html
> 
> I'll run my own set of non regression and if the results aren't too
> bad, then your new interface dispatch scheme will be good to go,
> eventually.

Things are looking good. Please have a look at the new patch
(attachement patch-2, also found below) for PR #108, then the plan is:

  - Fixes to 83, 94, 102, 107 to go in,
  - Your interface dispatch patch to go in, since the (your)
    understanding here is that it has been approved

Hopefully all this will happen tonight and no later than tomorrow.

80/145 will have to wait until we bring the 1.1 changes into egcs.

./A

1999-03-06  Bryce McKinlay <bryce@albatross.co.nz>

        * typeck.c (lookup_do): Search superinterfaces first
        when looking up an interface method. From Godmar Back
        <gback@cs.utah.edu>

2000-03-02  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * java-tree.h (lookup_argument_method2): Declared.
        (safe_layout_class): Prototype moved from parse.h.
        * parse.h (safe_layout_class): Prototype moved to java-tree.h.
        * parse.y (java_check_regular_methods): Local `super_class' gone.
        Call lookup_argument_method2 instead of lookup_argument_method.
        Perform modifier match for methods found declared in implemented
        interfaces. Fixed indentation problem. Overriding/hiding error
        report to take place only for methods found in classes.
        * typeck.c (lookup_argument_method): Changed leading
        comment. Re-written by calling lookup_do.
        (lookup_argument_method2): New function.
        (lookup_java_method): Re-written by calling lookup_do.
        (lookup_do): New function.

Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.56
diff -u -p -r1.56 java-tree.h
--- java-tree.h	2000/03/04 22:27:35	1.56
+++ java-tree.h	2000/03/07 01:23:33
@@ -510,6 +510,7 @@ extern tree lookup_class PARAMS ((tree))
 extern tree lookup_java_constructor PARAMS ((tree, tree));
 extern tree lookup_java_method PARAMS ((tree, tree, tree));
 extern tree lookup_argument_method PARAMS ((tree, tree, tree));
+extern tree lookup_argument_method2 PARAMS ((tree, tree, tree));
 extern tree promote_type PARAMS ((tree));
 extern tree get_constant PARAMS ((struct JCF*, int));
 extern tree get_name_constant PARAMS ((struct JCF*, int));
@@ -665,6 +666,7 @@ extern char* open_class PARAMS ((char *,
 # endif /* JCF_USE_STDIO */
 #endif
 void java_debug_context PARAMS ((void));
+void safe_layout_class PARAMS ((tree));
 
 extern tree get_boehm_type_descriptor PARAMS ((tree));
 
Index: parse.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
retrieving revision 1.45
diff -u -p -r1.45 parse.h
--- parse.h	2000/02/29 02:34:48	1.45
+++ parse.h	2000/03/07 01:23:33
@@ -678,7 +678,6 @@ struct parser_ctxt {
 };
 
 #ifndef JC1_LITE
-void safe_layout_class PARAMS ((tree));
 void java_complete_class PARAMS ((void));
 void java_check_circular_reference PARAMS ((void));
 void java_fix_constructors PARAMS ((void));
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.136
diff -u -p -r1.136 parse.y
--- parse.y	2000/02/26 02:05:35	1.136
+++ parse.y	2000/03/07 01:23:33
@@ -4762,7 +4762,7 @@ check_abstract_method_definitions (do_in
     }
 }
 
-/* Check that CLASS_DECL somehoow implements all inherited abstract
+/* Check that CLASS_DECL somehow implements all inherited abstract
    methods.  */
 
 static void
@@ -4807,7 +4807,6 @@ java_check_regular_methods (class_decl)
   int saw_constructor = 0;
   tree method;
   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
-  tree super_class = CLASSTYPE_SUPER (class);
   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
   tree mthrows;
 
@@ -4859,7 +4858,7 @@ java_check_regular_methods (class_decl)
 	}
 
       sig = build_java_argument_signature (TREE_TYPE (method));
-      found = lookup_argument_method (super_class, DECL_NAME (method), sig);
+      found = lookup_argument_method2 (class, DECL_NAME (method), sig);
 
       /* Nothing overrides or it's a private method. */
       if (!found)
@@ -4875,12 +4874,25 @@ java_check_regular_methods (class_decl)
       saved_found_wfl = DECL_NAME (found);
       reset_method_name (found);
 
+      /* If `found' is declared in an interface, make sure the
+	 modifier match. */
+      if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found))) 
+	  && clinit_identifier_node != DECL_NAME (found)
+	  && !METHOD_PUBLIC (method))
+	{
+	  tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
+	  parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
+			       IDENTIFIER_POINTER (DECL_NAME (class_decl)),
+			       lang_printable_name (method, 0),
+			       IDENTIFIER_POINTER (DECL_NAME (found_decl)));
+	}
+
       /* Can't override a method with the same name and different return
 	 types. */
       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
 	{
-	  char *t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
-						 0));
+	  char *t = xstrdup 
+	    (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
 	  parse_error_context 
 	    (method_wfl,
 	     "Method `%s' was defined with return type `%s' in class `%s'", 
@@ -4943,12 +4955,15 @@ java_check_regular_methods (class_decl)
 	 - Overriding/hiding protected must be protected or public
          - If the overriden or hidden method has default (package)
            access, then the overriding or hiding method must not be
-           private; otherwise, a compile-time error occurs */
-      if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method)) 
-	  || (METHOD_PROTECTED (found) 
-	      && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
-	  || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
-	      && METHOD_PRIVATE (method)))
+           private; otherwise, a compile-time error occurs.  If
+           `found' belongs to an interface, things have been already
+           taken care of.  */
+      if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
+	  && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
+	      || (METHOD_PROTECTED (found) 
+		  && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
+	      || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
+		  && METHOD_PRIVATE (method))))
 	{
 	  parse_error_context 
 	    (method_wfl,
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/typeck.c,v
retrieving revision 1.24
diff -u -p -r1.24 typeck.c
--- typeck.c	2000/02/26 19:56:23	1.24
+++ typeck.c	2000/03/07 01:23:33
@@ -37,6 +37,7 @@ The Free Software Foundation is independ
 static tree convert_ieee_real_to_integer PARAMS ((tree, tree));
 static tree parse_signature_type PARAMS ((const unsigned char **,
 					 const unsigned char *));
+static tree lookup_do PARAMS ((tree, tree, tree, tree, tree (*)(tree)));
 
 tree * type_map;
 extern struct obstack permanent_obstack;
@@ -713,106 +714,129 @@ set_java_signature (type, sig)
 #endif
 }
 
-/* Search in class CLAS (and its superclasses) for a method
+/* Search in class SEARCHED_CLASS (and its superclasses) for a method
    matching METHOD_NAME and argument signature METHOD_SIGNATURE.
    Return a FUNCTION_DECL on success, or NULL_TREE if none found.
-   (Contrast lookup_java_method, which takes into account return type.) */
+   (Contrast lookup_java_method, which takes into account return
+   type.) */
 
 tree
-lookup_argument_method (clas, method_name, method_signature)
-     tree clas, method_name, method_signature;
+lookup_argument_method (searched_class, method_name, method_signature)
+     tree searched_class, method_name, method_signature;
 {
-  tree method;
-  while (clas != NULL_TREE)
-    {
-      for (method = TYPE_METHODS (clas);
-	   method != NULL_TREE;  method = TREE_CHAIN (method))
-	{
-	  tree method_sig = build_java_argument_signature (TREE_TYPE (method));
-	  tree name = DECL_NAME (method);
-	  if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
-	       EXPR_WFL_NODE (name) : name) == method_name 
-	      && method_sig == method_signature)
-	    return method;
-	}
-      clas = CLASSTYPE_SUPER (clas);
-    }
-  return NULL_TREE;
+  return lookup_do (searched_class, NULL_TREE, method_name, method_signature, 
+		    build_java_argument_signature);
 }
 
-/* Search in class CLAS (and its superclasses) for a method
-   matching METHOD_NAME and signature METHOD_SIGNATURE.
-   Return a FUNCTION_DECL on success, or NULL_TREE if none found.
-   (Contrast lookup_argument_method, which ignores return type.) */
+/* Search in class SEARCHED_CLASS (and its superclasses and
+   implemented interfaces) for a method matching METHOD_NAME and
+   argument signature METHOD_SIGNATURE.  Return a FUNCTION_DECL on
+   success, or NULL_TREE if none found.  (Contrast lookup_java_method,
+   which takes into account return type.) */
 
 tree
-lookup_java_method (searched_class, method_name, method_signature)
+lookup_argument_method2 (searched_class, method_name, method_signature)
      tree searched_class, method_name, method_signature;
 {
-  tree method;
-  tree currently_searched = searched_class;
-
-  while (currently_searched != NULL_TREE)
-    {
-      for (method = TYPE_METHODS (currently_searched);
-	   method != NULL_TREE;  method = TREE_CHAIN (method))
-	{
-	  tree method_sig = build_java_signature (TREE_TYPE (method));
-	  tree name = DECL_NAME (method);
+  return lookup_do (CLASSTYPE_SUPER (searched_class), searched_class,
+		    method_name, method_signature, 
+		    build_java_argument_signature);
+}
 
-	  if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
-	       EXPR_WFL_NODE (name) : name) == method_name
-	      && method_sig == method_signature)
-	    return method;
-	}
-      currently_searched = CLASSTYPE_SUPER (currently_searched);
-    }
+/* Search in class SEARCHED_CLASS (and its superclasses) for a method
+   matching METHOD_NAME and signature METHOD_SIGNATURE.  Return a
+   FUNCTION_DECL on success, or NULL_TREE if none found.  (Contrast
+   lookup_argument_method, which ignores return type.) If
+   SEARCHED_CLASS is an interface, search it too. */
 
+tree
+lookup_java_method (searched_class, method_name, method_signature)
+     tree searched_class, method_name, method_signature;
+{
+  tree searched_interface;
+  
   /* If this class is an interface class, search its superinterfaces as
    * well.  A superinterface is not an interface's superclass: a
    * super interface is implemented by the interface.
    */
+
+  searched_interface = (CLASS_INTERFACE (TYPE_NAME (searched_class)) ?
+			searched_class : NULL_TREE);
+  return lookup_do (searched_class, searched_interface, method_name, 
+		    method_signature, build_java_signature);
+}
+
+/* Search in class SEARCHED_CLASS (an its superclasses) for a method
+   matching METHOD_NAME and signature SIGNATURE.  Also search in
+   SEARCHED_INTERFACE (an its superinterfaces) for a similar match.
+   Return the matched method DECL or NULL_TREE.  SIGNATURE_BUILDER is
+   used on method candidates to build their (sometimes partial)
+   signature.  */
 
-  currently_searched = searched_class;
-  if (CLASS_INTERFACE (TYPE_NAME (currently_searched)))
+static tree
+lookup_do (searched_class, searched_interface, method_name, signature, signature_builder)
+     tree searched_class, searched_interface, method_name, signature;
+     tree (*signature_builder) PARAMS ((tree));
+{
+  tree method;
+  
+  if (searched_interface)
     {
       int i;
       int interface_len = 
-	TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (currently_searched)) - 1;
+	TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (searched_interface)) - 1;
 
       for (i = interface_len; i > 0; i--)
        {
          tree child = 
-	   TREE_VEC_ELT (TYPE_BINFO_BASETYPES (currently_searched), i);
+	   TREE_VEC_ELT (TYPE_BINFO_BASETYPES (searched_interface), i);
          tree iclass = BINFO_TYPE (child);
 
          /* If the superinterface hasn't been loaded yet, do so now.  */
-         if (! CLASS_LOADED_P (iclass))
-           load_class (iclass, 1);
+	 if (CLASS_FROM_SOURCE_P (iclass))
+	   safe_layout_class (iclass);
+	 else if (!CLASS_LOADED_P (iclass))
+	   load_class (iclass, 1);
 
          for (method = TYPE_METHODS (iclass);
               method != NULL_TREE;  method = TREE_CHAIN (method))
            {
-             tree method_sig = build_java_signature (TREE_TYPE (method));
+             tree method_sig = (*signature_builder) (TREE_TYPE (method));
 	     tree name = DECL_NAME (method);
 
 	     if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
 		  EXPR_WFL_NODE (name) : name) == method_name
-		 && method_sig == method_signature)
+		 && method_sig == signature)
                return method;
            }
 
          /* it could be defined in a supersuperinterface */
          if (CLASS_INTERFACE (TYPE_NAME (iclass)))
            {
-             method = lookup_java_method (iclass, 
-					  method_name, 
-					  method_signature);
+             method = lookup_do (iclass, iclass, method_name, 
+				 signature, signature_builder);
              if (method != NULL_TREE) 
 	       return method;
            }
        }
     }
+
+  while (searched_class != NULL_TREE)
+    {
+      for (method = TYPE_METHODS (searched_class);
+	   method != NULL_TREE;  method = TREE_CHAIN (method))
+	{
+	  tree method_sig = (*signature_builder) (TREE_TYPE (method));
+	  tree name = DECL_NAME (method);
+
+	  if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
+	       EXPR_WFL_NODE (name) : name) == method_name
+	      && method_sig == signature)
+	    return method;
+	}
+      searched_class = CLASSTYPE_SUPER (searched_class);
+    }
+
   return NULL_TREE;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-04-01  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-01  0:00 Tested compiler PR patches Bryce McKinlay
2000-04-01  0:00 ` Alexandre Petit-Bianco
2000-04-01  0:00   ` Alexandre Petit-Bianco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).