This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Java: Cleanups and other fixes.


I'm checking in the following patch.

It brings some typos and other cleanups fixes. It also fixes
regressions I just saw when compiling some packages like XML and
JServ. And my personnal 1.1 tests (most of them are in libgcj's
testsuite) aren't showing regressions anymore.

./A

2000-07-06  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.h (BUILD_PTR_FROM_NAME): Surround with a do/while
	construct.
	* parse.y (find_as_inner_class): Fixed typo.
	(do_resolve_class): Explore enclosing contexts when searching for
	innerclasses. Removed curly brackets around BUILD_PTR_FROM_NAME.
	(check_inner_class_access): Check `decl' which can be null in case
	of previous errors.

2000-07-05  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* java-tree.h (java_debug_context): Declared `extern.'
	(safe_layout_class): Likewise.
	* parse.y (resolve_field_access): Field must be `static' in order
	to be replaced by its initial value. Added comments.
	(find_applicable_accessible_methods_list): Fixed typo.
	(find_most_specific_methods_list): Methods found in innerclasses
	take over methods founds in the enclosing contexts.
	(java_complete_tree): Loosen restrictions on the type of DECLs
	that can be replaced by their initialization values.
	(valid_ref_assignconv_cast_p): Removed call to `enclosing_context_p.'

Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.74
diff -u -p -r1.74 java-tree.h
--- java-tree.h	2000/06/27 04:30:18	1.74
+++ java-tree.h	2000/07/07 04:58:10
@@ -779,8 +779,8 @@ extern const char* open_class PARAMS ((c
 				       int, const char *));
 # endif /* JCF_USE_STDIO */
 #endif
-void java_debug_context PARAMS ((void));
-void safe_layout_class PARAMS ((tree));
+extern void java_debug_context PARAMS ((void));
+extern void safe_layout_class PARAMS ((tree));
 
 extern tree get_boehm_type_descriptor PARAMS ((tree));
 extern unsigned long java_hash_hash_tree_node PARAMS ((hash_table_key));
Index: parse.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
retrieving revision 1.54
diff -u -p -r1.54 parse.h
--- parse.h	2000/06/22 05:17:35	1.54
+++ parse.h	2000/07/07 04:59:01
@@ -156,10 +156,10 @@ extern tree stabilize_reference PARAMS (
 
 /* Quickly build a temporary pointer on hypothetical type NAME. */
 #define BUILD_PTR_FROM_NAME(ptr, name)		\
-  {						\
+  do {						\
     ptr = build (POINTER_TYPE, NULL_TREE);	\
     TYPE_NAME (ptr) = name;			\
-  }
+  } while (0)
 
 #define INCOMPLETE_TYPE_P(NODE)				\
   ((TREE_CODE (NODE) == POINTER_TYPE)			\
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.189
diff -u -p -r1.189 parse.y
--- parse.y	2000/07/07 00:49:36	1.189
+++ parse.y	2000/07/07 04:59:37
@@ -3471,8 +3471,8 @@ find_as_inner_class (enclosing, name, cl
     {
       tree acc = NULL_TREE, decl = NULL_TREE, ptr;
 
-      for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
-	  qual = TREE_CHAIN (qual))
+      for (qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
+	   qual = TREE_CHAIN (qual))
 	{
 	  acc = merge_qualified_name (acc, 
 				      EXPR_WFL_NODE (TREE_PURPOSE (qual)));
@@ -5438,6 +5438,15 @@ do_resolve_class (enclosing, class_type,
       if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
         return new_class_decl;
 
+      /* Explore enclosing contexts. */
+      while (INNER_CLASS_DECL_P (enclosing))
+	{
+	  enclosing = DECL_CONTEXT (enclosing);
+	  if ((new_class_decl = find_as_inner_class (enclosing, 
+						     class_type, cl)))
+	    return new_class_decl;
+	}
+
       /* Now go to the upper classes, bail out if necessary. */
       enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
       if (!enclosing || enclosing == object_type_node)
@@ -5450,9 +5459,7 @@ do_resolve_class (enclosing, class_type,
 	}
 
       if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
-	{
-	  BUILD_PTR_FROM_NAME (name, enclosing);
-	}
+	BUILD_PTR_FROM_NAME (name, enclosing);
       else
 	name = enclosing;
       enclosing = do_resolve_class (NULL, name, NULL, NULL);
@@ -6777,6 +6784,8 @@ static void
 check_inner_class_access (decl, enclosing_type, cl)
      tree decl, enclosing_type, cl;
 {
+  if (!decl)
+    return;
   /* We don't issue an error message when CL is null. CL can be null
      as a result of processing a JDEP crafted by
      source_start_java_method for the purpose of patching its parm
@@ -8740,10 +8749,13 @@ resolve_field_access (qual_wfl, field_de
       if (!type_found)
 	type_found = DECL_CONTEXT (decl);
       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
-      if (FIELD_FINAL (decl) 
+      if (FIELD_FINAL (decl) && FIELD_STATIC (decl)
 	  && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
 	  && DECL_INITIAL (decl))
 	{
+	  /* When called on a FIELD_DECL of the right (primitive)
+	     type, java_complete_tree will try to substitue the decl
+	     for it's initial value. */
 	  field_ref = java_complete_tree (decl);
 	  static_final_found = 1;
 	}
@@ -10114,7 +10126,7 @@ find_applicable_accessible_methods_list 
     
   search_not_done++;
   hash_lookup (searched_classes, 
-              (const hash_table_key) class, TRUE, NULL);
+	       (const hash_table_key) class, TRUE, NULL);
 
   if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
     {
@@ -10268,19 +10280,27 @@ find_most_specific_methods_list (list)
 
       for (method = list; method; method = TREE_CHAIN (method))
 	{
+	  tree method_v, current_v;
 	  /* Don't test a method against itself */
 	  if (method == current)
 	    continue;
+
+	  method_v = TREE_VALUE (method);
+	  current_v = TREE_VALUE (current);
 
-	  /* Compare arguments and location where method where declared */
-	  if (argument_types_convertible (TREE_VALUE (method), 
-					  TREE_VALUE (current))
-	      && valid_method_invocation_conversion_p 
-	           (DECL_CONTEXT (TREE_VALUE (method)), 
-		    DECL_CONTEXT (TREE_VALUE (current))))
+	  /* Compare arguments and location where methods where declared */
+	  if (argument_types_convertible (method_v, current_v))
 	    {
-	      int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
-	      max = (v > max ? v : max);
+	      if (valid_method_invocation_conversion_p 
+		  (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v))
+		  || (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v))
+		      && enclosing_context_p (DECL_CONTEXT (method_v),
+					      DECL_CONTEXT (current_v))))
+		{
+		  int v = (DECL_SPECIFIC_COUNT (current_v) += 
+		    (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v)) ? 2 : 1));
+		  max = (v > max ? v : max);
+		}
 	    }
 	}
     }
@@ -10617,8 +10637,8 @@ java_complete_tree (node)
      tree node;
 {
   node = java_complete_lhs (node);
-  if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
-      && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
+  if (JDECL_P (node) && FIELD_STATIC (node) && FIELD_FINAL (node) 
+      && DECL_INITIAL (node) != NULL_TREE
       && !flag_emit_xref)
     {
       tree value = DECL_INITIAL (node);
@@ -12068,7 +12088,6 @@ valid_ref_assignconv_cast_p (source, des
       if (TYPE_CLASS_P (dest))
 	return  (source == dest 
 		 || inherits_from_p (source, dest)
-		 || enclosing_context_p (source, dest)
 		 || (cast && inherits_from_p (dest, source)));
       if (TYPE_INTERFACE_P (dest))
 	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]