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 - misc gcj patches


I've checked these into egcs.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner

Fri Mar  5 15:17:29 1999  Per Bothner  <bothner@cygnus.com>

	* lex.c (java_parse_end_comment):  Take extra parameter (next char).

	* class.c (build_utf8_ref):  Fix possible name class/ambiguity.

	* class.c (layout_class_method):  A static method in a base class
	is never overridden, so treat it like it doesn't exist.
	However, do complain about private non-static method overriding
	public static method.

	* parse.y:  Don't set unused INITIALIZED_P flag.
	* java-tree.h (INITIALIZED_P):  Removed no-longer needed flag.

	* parse.y (find_expr_with_wfl):  Optimize tail-calls.
	(build_array_from_name):  Re-order &index[string] to &string[index].

	* parse.y (java_complete_tree):  Don't call patch_assignment if rhs is
	error_mark (it might catch more errors, but it is more likely to lose).

Index: lex.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/lex.c,v
retrieving revision 1.40
diff -u -p -r1.40 lex.c
--- lex.c	1999/02/20 00:38:57	1.40
+++ lex.c	1999/03/08 20:23:58
@@ -62,7 +62,7 @@ static void java_store_unicode PROTO ((s
 static unicode_t java_parse_escape_sequence PROTO (());
 static int java_letter_or_digit_p PROTO ((unicode_t));
 static int java_parse_doc_section PROTO ((unicode_t));
-static void java_parse_end_comment PROTO (());
+static void java_parse_end_comment PROTO ((unicode_t));
 static unicode_t java_get_unicode PROTO (());
 static unicode_t java_read_unicode PROTO ((int, int *));
 static void java_store_unicode PROTO ((struct java_line *, unicode_t, int));
@@ -364,13 +364,14 @@ java_lineterminator (c)
     return 0;
 }
 
-/* Parse the end of a C style comment */
+/* Parse the end of a C style comment.
+ * C is the first character after the '/*'. */
 static void
-java_parse_end_comment ()
+java_parse_end_comment (c)
+     unicode_t c;
 {
-  unicode_t c;
 
-  for (c = java_get_unicode ();; c = java_get_unicode ())
+  for ( ;; c = java_get_unicode ())
     {
       switch (c)
 	{
@@ -557,8 +558,9 @@ java_lex (java_lval)
       switch (c = java_get_unicode ())
 	{
 	case '/':
-	  for (c = java_get_unicode ();;c = java_get_unicode ())
+	  for (;;)
 	    {
+	      c = java_get_unicode ();
 	      if (c == UEOF)
 		java_lex_error ("Comment not terminated at end of input", 0);
 	      if (c == '\n')	/* ULT */
@@ -574,10 +576,8 @@ java_lex (java_lval)
 	      else if (java_parse_doc_section (c))
 		goto step1;
 	    }
-	  else
-	    java_unget_unicode ();
 
-	  java_parse_end_comment ();
+	  java_parse_end_comment (c);
 	  goto step1;
 	  break;
 	default:
Index: class.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/class.c,v
retrieving revision 1.62
diff -u -p -r1.62 class.c
--- class.c	1999/02/19 22:59:22	1.62
+++ class.c	1999/03/08 20:23:59
@@ -568,6 +568,8 @@ build_utf8_ref (name)
   /* Build a unique identifier based on buf. */
   sprintf(buf, "_Utf%d", ++utf8_count);
   buf_ptr = &buf[strlen (buf)];
+  if (name_len > 0 && name_ptr[0] >= '0' && name_ptr[0] <= '9')
+    *buf_ptr++ = '_';
   while (--name_len >= 0)
     {
       unsigned char c = *name_ptr++;
@@ -1627,11 +1629,10 @@ layout_class_method (this_class, super_c
 	build_java_argument_signature (TREE_TYPE (method_decl));
       tree super_method = lookup_argument_method (super_class, method_name,
 						  method_sig);
-      if (super_method != NULL_TREE)
+      if (super_method != NULL_TREE && ! METHOD_PRIVATE (super_method))
 	{
 	  DECL_VINDEX (method_decl) = DECL_VINDEX (super_method);
-	  if (DECL_VINDEX (method_decl) == NULL_TREE &&
-	      ! TREE_PRIVATE (method_decl))
+	  if (DECL_VINDEX (method_decl) == NULL_TREE)
 	    error_with_decl (method_decl,
 			     "non-static method '%s' overrides static method");
 #if 0
Index: parse.y
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/parse.y,v
retrieving revision 1.55
diff -u -p -r1.55 parse.y
--- parse.y	1999/02/25 20:49:23	1.55
+++ parse.y	1999/03/08 20:23:59
@@ -2537,20 +2537,24 @@ find_expr_with_wfl (node)
       switch (TREE_CODE (node))
 	{
 	case BLOCK:
-	  return find_expr_with_wfl (BLOCK_EXPR_BODY (node));
+	  node = BLOCK_EXPR_BODY (node);
+	  continue;
 
 	case COMPOUND_EXPR:
 	  to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
 	  if (to_return)
 	    return to_return;
-	  to_return = find_expr_with_wfl (TREE_OPERAND (node, 1));
-	  return to_return;
+	  node = TREE_OPERAND (node, 1);
+	  continue;
 
 	case LOOP_EXPR:
-	  return find_expr_with_wfl (TREE_OPERAND (node, 0));
+	  node = TREE_OPERAND (node, 0);
+	  continue;
 	  
 	case LABELED_BLOCK_EXPR:
-	  return find_expr_with_wfl (TREE_OPERAND (node, 1));
+	  node = TREE_OPERAND (node, 1);
+	  continue;
+
 	default:
 	  code = TREE_CODE_CLASS (TREE_CODE (node));
 	  if (((code == '1') || (code == '2') || (code == 'e'))
@@ -2684,7 +2688,7 @@ build_array_from_name (type, type_wfl, n
   /* If we have, then craft a new type for this variable */
   if (more_dims)
     {
-      name = get_identifier (&more_dims [string]);
+      name = get_identifier (&string [more_dims]);
 
       /* If we have a pointer, use its type */
       if (TREE_CODE (type) == POINTER_TYPE)
@@ -3160,11 +3164,6 @@ register_fields (flags, type, variable_l
       if (must_chain)
 	register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
 	  
-      /* Default value of a static field is 0 and it is considered
-	 initialized. */
-      if (flags & ACC_STATIC)
-	INITIALIZED_P (field_decl) = 1;
-      
       /* If we have an initialization value tied to the field */
       if (init)
 	{
@@ -3191,7 +3190,6 @@ register_fields (flags, type, variable_l
 	      TREE_CHAIN (init) = ctxp->non_static_initialized;
 	      ctxp->non_static_initialized = init;
 	    }
-	  INITIALIZED_P (field_decl) = 1;
 	  MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
 	}
     }
@@ -3333,7 +3331,7 @@ method_header (flags, type, mdecl, throw
 
   /* Method declared within the scope of an interface are implicitly
      abstract and public. Conflicts with other erroneously provided
-     modifiers are check right after. */
+     modifiers are checked right after. */
 
   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
     {
@@ -5457,7 +5455,6 @@ expand_start_java_method (fndecl)
       DECL_ARG_TYPE (tem) = type;
       layout_decl (tem, 0);
       pushdecl (tem);
-      INITIALIZED_P (tem) = 1;	/* Parms are initialized */
       *ptr = tem;
       ptr = &TREE_CHAIN (tem);
       tem = next;
@@ -7551,7 +7548,6 @@ java_complete_lhs (node)
 	{
 	  DECL_CONTEXT (cn) = current_function_decl;
 	  IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
-	  INITIALIZED_P (cn) = 0;
 	}
       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
 	  CAN_COMPLETE_NORMALLY (node) = 1;
@@ -7935,25 +7931,8 @@ java_complete_lhs (node)
       else
 	nn = java_complete_tree (TREE_OPERAND (node, 1));
 
-      /* There are cases where the type of RHS is fixed. In those
-	 cases, if the evaluation of the RHS fails, we further the
-	 evaluation of the assignment to detect more errors. */
       if (nn == error_mark_node)
-	{
-	  /* It's hopeless, but we can further things on to discover
-	     an error during the assignment. In any cases, the
-	     assignment operation fails. */
-	  if (TREE_CODE (TREE_OPERAND (node, 1)) != EXPR_WITH_FILE_LOCATION
-	      && TREE_CODE (TREE_OPERAND (node, 1)) != NEW_ARRAY_INIT
-	      && TREE_TYPE (TREE_OPERAND (node, 1)) != error_mark_node)
-	    patch_assignment (node, wfl_op1, wfl_op2);
-
-	  /* Now, we still mark the lhs as initialized */
-	  if (JDECL_P (TREE_OPERAND (node, 0)))
-	    INITIALIZED_P (TREE_OPERAND (node, 0)) = 1;
-
-	  return error_mark_node;
-	}
+	return error_mark_node;
       TREE_OPERAND (node, 1) = nn;
 
       /* In case we're handling = with a String as a RHS, we need to
@@ -8448,7 +8427,6 @@ patch_assignment (node, wfl_op1, wfl_op2
   /* Lhs can be a named variable */
   if (JDECL_P (lvalue))
     {
-      INITIALIZED_P (lvalue) = 1;
       lhs_type = TREE_TYPE (lvalue);
     }
   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
@@ -9386,13 +9364,13 @@ build_string_concatenation (op1, op2)
   if ((result = string_constant_concatenation (op1, op2)))
     return result;
 
-  /* Discard null constants on either sides of the expression */
-  if (TREE_CODE (op1) == STRING_CST && !TREE_STRING_LENGTH (op1))
+  /* Discard empty strings on either side of the expression */
+  if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
     {
       op1 = op2;
       op2 = NULL_TREE;
     }
-  else if (TREE_CODE (op2) == STRING_CST && !TREE_STRING_LENGTH (op2))
+  else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
     op2 = NULL_TREE;
 
   /* If operands are string constant, turn then into object references */
Index: java-tree.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/java-tree.h,v
retrieving revision 1.66
diff -u -p -r1.66 java-tree.h
--- java-tree.h	1999/02/21 23:47:59	1.66
+++ java-tree.h	1999/03/08 20:23:59
@@ -90,7 +90,6 @@ struct JCF;
    6: METHOD_TRANSIENT (in FUNCTION_DECL)
       LABEL_CHANGED (in LABEL_DECL)
       CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag)
-      INITIALIZED_P (in FIELD_DECL, VAR_DECL, PARM_DECL)
    7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL).
 */
 
@@ -615,10 +614,6 @@ extern tree force_evaluation_order PROTO
 #define FIELD_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
 #define FIELD_VOLATILE(DECL) DECL_LANG_FLAG_4 (DECL)
 #define FIELD_TRANSIENT(DECL) DECL_LANG_FLAG_5 (DECL)
-
-/* Initialized flag on variable/field/parm decl */
-
-#define INITIALIZED_P(DECL) DECL_LANG_FLAG_6 (DECL)
 
 /* Access flags etc for a class (a TYPE_DECL): */
 


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