java patch: moving important changes to the 2.95 branch

Anthony Green green@cygnus.com
Sat Jun 5 08:19:00 GMT 1999


The following changes have been in the trunk for some time.  They are
very important, and I'm committing them to the 2.95 release branch.

Wed Jun  2 10:44:38 1999  Anthony Green  <green@cygnus.com>

	* except.c (link_handler): Chain exception handlers in order.

Wed Jun  2 10:41:24 1999  Anthony Green  <green@cygnus.com>

	* expr.c (expand_byte_code): Fill unreachable bytecode regions
 	with nops and process as usual in order to always set correct EH
 	ranges.  Emit detailed warnings about unreachable bytecodes.

Wed Jun  2 10:35:13 1999  Anthony Green  <green@cygnus.com>

	* class.c (build_utf8_ref): Mark cinit and utf8 tree nodes as
 	constant.

Fri May 28 18:22:45 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * parse.y (lookup_field_wrapper): Unified returned value to NULL
          or the searched field decl.
	
Fri May 28 11:34:05 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (fold_constant_for_init): Convert numerical constant
 	values to the type of the assigned field.

Thu May 27 19:57:40 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* expr.c (lookup_field): Relaxed the test on class loading error
 	detection.
	* parse.y (fold_constant_for_init): Enabeled old code.

Wed May 26 18:06:02 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (valid_ref_assignconv_cast_p): Let `_Jv_CheckCast'
 	decide the validity of the cast of a java.lang.Cloneable reference
 	to an array.
	(patch_conditional_expr): Fixed first argument passed to
 	binary_numeric_promotion.

Wed May 26 15:33:06 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (qualify_ambiguous_name): Take into account that a
 	CONVERT_EXPR might specify a type as a WFL.

Tue May 25 15:06:13 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
        * parse.y (patch_assignment): Save the rhs before using it as an
        argument to _Jv_CheckArrayStore.
 
Tue May 25 11:23:59 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* lex.c (java_parse_doc_section): Fixed `tag' buffer size.

Mon May 24 13:26:00 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * lex.c (java_lex): Accepts `+' or `-' after the beginning of a
        floating point litteral only when the exponent indicator has been
        parsed.

Sat May 22 13:54:41 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (formal_parameter:): Construct argument tree list
 	element even if a yet unsupported final parameter was encountered.

Tue May 18 00:28:58 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (finish_method_declaration): Issue errors for native or
 	abstract methods declared with a method body, as well as for non
 	native or non abstract methods with no method body.

1999-05-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* class.c (build_utf8_ref): Initialize variable `field'.

	* decl.c (init_decl_processing): Initialize variable `field'.

	* expr.c (build_known_method_ref): Mark parameters `method_type',
	`method_signature' and `arg_list' with ATTRIBUTE_UNUSED.
	(process_jvm_instruction): Likewise for parameter `length'.

	* jvspec.c (lang_specific_driver): Mark variables `saw_math',
	`saw_libc', `saw_gc', `saw_threadlib' and `saw_libgcj' with
	ATTRIBUTE_UNUSED.

	* parse.y (maybe_generate_clinit): Remove unused variable
	`has_non_primitive_fields'.
	(find_in_imports_on_demand): Initialize variables `node_to_use'
	and `cl'.
	(patch_binop): Likewise for variable `prom_type'.
	(patch_unaryop): Likewise for variable `prom_type'.

	* verify.c (verify_jvm_instructions): Likewise for variable `last'.

	* xref.c (xref_table): Add missing initializer.

Index: gcc/java/class.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/class.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 class.c
--- class.c	1999/05/05 21:09:57	1.38
+++ class.c	1999/06/05 15:07:14
@@ -559,7 +559,7 @@ build_utf8_ref (name)
   int name_len = IDENTIFIER_LENGTH(name);
   char buf[60];
   char *buf_ptr;
-  tree ctype, field, str_type, cinit, string;
+  tree ctype, field = NULL_TREE, str_type, cinit, string;
   static int utf8_count = 0;
   int name_hash;
   tree ref = IDENTIFIER_UTF8_REF (name);
@@ -583,6 +583,7 @@ build_utf8_ref (name)
   TREE_TYPE (string) = str_type;
   PUSH_FIELD_VALUE (cinit, "data", string);
   FINISH_RECORD_CONSTRUCTOR (cinit);
+  TREE_CONSTANT (cinit) = 1;
 
   /* Build a unique identifier based on buf. */
   sprintf(buf, "_Utf%d", ++utf8_count);
@@ -608,6 +609,7 @@ build_utf8_ref (name)
   DECL_ARTIFICIAL (decl) = 1;
   DECL_IGNORED_P (decl) = 1;
   TREE_READONLY (decl) = 1;
+  TREE_THIS_VOLATILE (decl) = 0;
   DECL_INITIAL (decl) = cinit;
   TREE_CHAIN (decl) = utf8_decl_list;
   layout_decl (decl, 0);
Index: gcc/java/decl.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/decl.c,v
retrieving revision 1.30
diff -u -p -u -r1.30 decl.c
--- decl.c	1999/05/11 12:09:13	1.30
+++ decl.c	1999/06/05 15:07:14
@@ -432,7 +432,7 @@ void
 init_decl_processing ()
 {
   register tree endlink;
-  tree field;
+  tree field = NULL_TREE;
   tree t;
 
   current_function_decl = NULL;
Index: gcc/java/expr.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/expr.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 expr.c
--- expr.c	1999/05/12 17:04:28	1.35
+++ expr.c	1999/06/05 15:07:15
@@ -1162,7 +1162,7 @@ lookup_field (typep, name)
   if (CLASS_P (*typep) && !CLASS_LOADED_P (*typep))
     {
       load_class (*typep, 1);
-      if (TREE_CODE (TYPE_SIZE (*typep)) == ERROR_MARK)
+      if (!TYPE_SIZE (*typep) || TREE_CODE (TYPE_SIZE (*typep)) == ERROR_MARK)
 	return error_mark_node;
     }
   do
@@ -1431,7 +1431,8 @@ tree dtable_ident = NULL_TREE;
 
 tree
 build_known_method_ref (method, method_type, self_type, method_signature, arg_list)
-     tree method, method_type, self_type, method_signature, arg_list;
+     tree method, method_type ATTRIBUTE_UNUSED, self_type,
+          method_signature ATTRIBUTE_UNUSED, arg_list ATTRIBUTE_UNUSED;
 {
   tree func;
   if (is_compiled_class (self_type))
@@ -1985,6 +1986,7 @@ expand_byte_code (jcf, method)
   int i;
   int saw_index;
   unsigned char *linenumber_pointer;
+  int dead_code_index = -1;
 
 #undef RET /* Defined by config/i386/i386.h */
 #undef AND /* Causes problems with opcodes for iand and land. */
@@ -2163,15 +2165,29 @@ expand_byte_code (jcf, method)
 
       if (! (instruction_bits [PC] & BCODE_VERIFIED))
 	{
-	  /* never executed - skip */
-	  warning ("Some bytecode operations (starting at pc %d) can never be executed", PC);
-	  while (PC < length
-		 && ! (instruction_bits [PC] & BCODE_VERIFIED))
-	    PC++;
-	  continue;
+	  if (dead_code_index == -1)
+	    {
+	      /* This is the start of a region of unreachable bytecodes.
+                 They still need to be processed in order for EH ranges
+                 to get handled correctly.  However, we can simply
+                 replace these bytecodes with nops.  */
+	      dead_code_index = PC;
+            }
+          
+          /* Turn this bytecode into a nop.  */
+          byte_ops[PC] = 0x0;
+        }
+       else
+        {
+	  if (dead_code_index != -1)
+	    {
+              /* We've just reached the end of a region of dead code.  */
+              warning ("Unreachable bytecode from %d to before %d.",
+                       dead_code_index, PC);
+              dead_code_index = -1;
+            }
 	}
 
-
       /* Handle possible line number entry for this PC.
 
 	 This code handles out-of-order and multiple linenumbers per PC,
@@ -2203,6 +2219,13 @@ expand_byte_code (jcf, method)
       maybe_poplevels (PC);
       maybe_end_try (PC);
     } /* for */
+  
+  if (dead_code_index != -1)
+    {
+      /* We've just reached the end of a region of dead code.  */
+      warning ("Unreachable bytecode from %d to the end of the method.", 
+              dead_code_index);
+    }
 }
 
 static void
@@ -2230,7 +2253,7 @@ int
 process_jvm_instruction (PC, byte_ops, length)
      int PC;
      unsigned char* byte_ops;
-     long length;
+     long length ATTRIBUTE_UNUSED;
 { 
   const char *opname; /* Temporary ??? */
   int oldpc = PC; /* PC at instruction start. */
Index: gcc/java/jvspec.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/jvspec.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 jvspec.c
--- jvspec.c	1999/05/11 12:00:35	1.17
+++ jvspec.c	1999/06/05 15:07:15
@@ -145,19 +145,19 @@ lang_specific_driver (fn, in_argc, in_ar
   int saw_speclang = 0;
 
   /* "-lm" or "-lmath" if it appears on the command line.  */
-  char *saw_math = 0;
+  char *saw_math ATTRIBUTE_UNUSED = 0;
 
   /* "-lc" if it appears on the command line.  */
-  char *saw_libc = 0;
+  char *saw_libc ATTRIBUTE_UNUSED = 0;
 
   /* "-lgcjgc" if it appears on the command line.  */
-  char *saw_gc = 0;
+  char *saw_gc ATTRIBUTE_UNUSED = 0;
 
   /* Saw `-l' option for the thread library.  */
-  char *saw_threadlib = 0;
+  char *saw_threadlib ATTRIBUTE_UNUSED = 0;
 
   /* Saw `-lgcj' on command line.  */
-  int saw_libgcj = 0;
+  int saw_libgcj ATTRIBUTE_UNUSED = 0;
 
   /* Saw -C or -o option, respectively. */
   int saw_C = 0;
Index: gcc/java/lex.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/lex.c,v
retrieving revision 1.30
diff -u -p -u -r1.30 lex.c
--- lex.c	1999/05/03 16:45:06	1.30
+++ lex.c	1999/06/05 15:07:15
@@ -427,7 +427,7 @@ java_parse_doc_section (c)
   /* We're parsing @deprecated */
   if (valid_tag && (c == '@'))
     {
-      char tag [10];
+      char tag [11];
       int  tag_index = 0;
 
       while (tag_index < 10 && c != UEOF && c != ' ' && c != '\n')
@@ -741,7 +741,7 @@ java_lex (java_lval)
 		  stage = 4;	/* So we fall through */
 		}
 
-	      if ((c=='-' || c =='+') && stage < 3)
+	      if ((c=='-' || c =='+') && stage == 2)
 		{
 		  stage = 3;
 		  literal_token [literal_index++] = c;
Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/parse.y,v
retrieving revision 1.85
diff -u -p -u -r1.85 parse.y
--- parse.y	1999/05/17 19:33:13	1.85
+++ parse.y	1999/06/05 15:07:17
@@ -917,7 +917,10 @@ formal_parameter:
 		  $$ = build_tree_list ($2, $1);
 		}
 |	modifiers type variable_declarator_id /* Added, JDK1.1 final parms */
-		{ $$ = parse_jdk1_1_error ("final parameters"); }
+		{ 
+		  parse_jdk1_1_error ("final parameters");
+		  $$ = build_tree_list ($3, $2);
+		}
 |	type error
 		{yyerror ("Missing identifier"); RECOVER;}
 |	modifiers type error
@@ -3078,7 +3081,7 @@ lookup_field_wrapper (class, name)
   java_parser_context_save_global ();
   decl = lookup_field (&type, name);
   java_parser_context_restore_global ();
-  return decl;
+  return decl == error_mark_node ? NULL : decl;
 }
 
 /* Find duplicate field within the same class declarations and report
@@ -3265,7 +3268,6 @@ static void
 maybe_generate_clinit ()
 {
   tree mdecl, c;
-  int has_non_primitive_fields = 0;
 
   if (!ctxp->static_initialized || java_error_count)
     return;
@@ -3517,6 +3519,29 @@ static void
 finish_method_declaration (method_body)
      tree method_body;
 {
+  int flags = get_access_flags_from_decl (current_function_decl);
+
+  /* 8.4.5 Method Body */
+  if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
+    {
+      tree wfl = DECL_NAME (current_function_decl);
+      parse_error_context (wfl, 
+			   "%s method `%s' can't have a body defined",
+			   (METHOD_NATIVE (current_function_decl) ?
+			    "Native" : "Abstract"),
+			   IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
+      method_body = NULL_TREE;
+    }
+  else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
+    {
+      tree wfl = DECL_NAME (current_function_decl);
+      parse_error_context (wfl, 
+			   "Non native and non abstract method `%s' must "
+			   "have a body defined",
+			   IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
+      method_body = NULL_TREE;
+    }
+
   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
   maybe_absorb_scoping_blocks ();
   /* Exit function's body */
@@ -5150,9 +5175,9 @@ static int
 find_in_imports_on_demand (class_type)
      tree class_type;
 {
-  tree node, import, node_to_use;
+  tree node, import, node_to_use = NULL_TREE;
   int seen_once = -1;
-  tree cl;
+  tree cl = NULL_TREE;
 
   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
     {
@@ -7580,9 +7605,15 @@ qualify_ambiguous_name (id)
 	|| TREE_CODE (qual_wfl) == STRING_CST
 	|| TREE_CODE (qual_wfl) == CONVERT_EXPR)
       {
-	qual = TREE_CHAIN (qual);
-	qual_wfl = QUAL_WFL (qual);
-	again = 1;
+	if (TREE_CODE (qual_wfl) == CONVERT_EXPR
+	    && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
+	    name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
+	else
+	  {
+	    qual = TREE_CHAIN (qual);
+	    qual_wfl = QUAL_WFL (qual);
+	    again = 1;
+	  }
       }
   } while (again);
   
@@ -8822,6 +8853,7 @@ patch_assignment (node, wfl_op1, wfl_op2
 	}
 
       /* Build the invocation of _Jv_CheckArrayStore */
+      new_rhs = save_expr (new_rhs);
       check = build (CALL_EXPR, void_type_node,
 		     build_address_of (soft_checkarraystore_node),
 		     tree_cons (NULL_TREE, base,
@@ -9065,7 +9097,8 @@ valid_ref_assignconv_cast_p (source, des
 	    return source == dest || interface_of_p (dest, source);
 	}
       else			/* Array */
-	return 0;
+	return (cast ? 
+		(DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
     }
   if (TYPE_ARRAY_P (source))
     {
@@ -9226,7 +9259,7 @@ patch_binop (node, wfl_op1, wfl_op2)
   tree op2 = TREE_OPERAND (node, 1);
   tree op1_type = TREE_TYPE (op1);
   tree op2_type = TREE_TYPE (op2);
-  tree prom_type;
+  tree prom_type = NULL_TREE;
   int code = TREE_CODE (node);
 
   /* If 1, tell the routine that we have to return error_mark_node
@@ -9852,7 +9885,7 @@ patch_unaryop (node, wfl_op)
 {
   tree op = TREE_OPERAND (node, 0);
   tree op_type = TREE_TYPE (op);
-  tree prom_type, value, decl;
+  tree prom_type = NULL_TREE, value, decl;
   int code = TREE_CODE (node);
   int error_found = 0;
 
@@ -11432,7 +11465,7 @@ patch_conditional_expr (node, wfl_cond, 
       /* Otherwise, binary numeric promotion is applied and the
 	 resulting type is the promoted type of operand 1 and 2 */
       else 
-	resulting_type = binary_numeric_promotion (t2, t2, 
+	resulting_type = binary_numeric_promotion (t1, t2, 
 						   &TREE_OPERAND (node, 1), 
 						   &TREE_OPERAND (node, 2));
     }
@@ -11489,8 +11522,11 @@ fold_constant_for_init (node, context)
   tree op0, op1, val;
   enum tree_code code = TREE_CODE (node);
 
-  if (code == INTEGER_CST || code == REAL_CST || code == STRING_CST)
+  if (code == STRING_CST)
     return node;
+
+  if (code == INTEGER_CST || code == REAL_CST)
+    return convert (TREE_TYPE (context), node);
   if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL)
     return NULL_TREE;
 
@@ -11585,13 +11621,11 @@ fold_constant_for_init (node, context)
 	    }
 	  else
 	    {
-#if 0
 	      /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
 	      qualify_ambiguous_name (node);
 	      if (resolve_field_access (node, &decl, NULL)
 		  && decl != NULL_TREE)
 		return fold_constant_for_init (decl, decl);
-#endif
 	      return NULL_TREE;
 	    }
 	}
Index: gcc/java/xref.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/xref.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 xref.c
--- xref.c	1999/05/14 13:44:10	1.6
+++ xref.c	1999/06/05 15:07:17
@@ -35,7 +35,7 @@ The Free Software Foundation is independ
 
 
 static xref_flag_table xref_table [] = {
-  {NULL, NULL, NULL},
+  {NULL, NULL, NULL, NULL},
 };
 
 /* Decode an xref flag value. Return 0 if the flag wasn't found. */



More information about the Gcc-patches mailing list