OSDN Git Service

* parse.y (build_super_invocation): Adjust declaration order to
[pf3gnuchains/gcc-fork.git] / gcc / java / parse.y
index aa5bc2c..94b74e3 100644 (file)
@@ -1,6 +1,6 @@
 /* Source code parsing and tree node generation for the GNU compiler
    for the Java(TM) language.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
 
@@ -71,9 +71,12 @@ definitions and other extensions.  */
 #include "ggc.h"
 #include "debug.h"
 #include "tree-inline.h"
+#include "cgraph.h"
+#include "target.h"
 
 /* Local function prototypes */
 static char *java_accstring_lookup (int);
+static const char *accessibility_string (int);
 static void  classitf_redefinition_error (const char *,tree, tree, tree);
 static void  variable_redefinition_error (tree, tree, tree, int);
 static tree  create_class (int, tree, tree, tree);
@@ -104,7 +107,7 @@ static void read_import_dir (tree);
 static int find_in_imports_on_demand (tree, tree);
 static void find_in_imports (tree, tree);
 static void check_inner_class_access (tree, tree, tree);
-static int check_pkg_class_access (tree, tree, bool);
+static int check_pkg_class_access (tree, tree, bool, tree);
 static void register_package (tree);
 static tree resolve_package (tree, tree *, tree *);
 static tree resolve_class (tree, tree, tree, tree);
@@ -119,8 +122,6 @@ static tree resolve_expression_name (tree, tree *);
 static tree maybe_create_class_interface_decl (tree, tree, tree, tree);
 static int check_class_interface_creation (int, int, tree, tree, tree, tree);
 static tree patch_method_invocation (tree, tree, tree, int, int *, tree *);
-static int breakdown_qualified (tree *, tree *, tree);
-static int in_same_package (tree, tree);
 static tree resolve_and_layout (tree, tree);
 static tree qualify_and_find (tree, tree, tree);
 static tree resolve_no_layout (tree, tree);
@@ -195,7 +196,6 @@ static void check_deprecation (tree, tree);
 static int class_in_current_package (tree);
 static tree build_if_else_statement (int, tree, tree, tree);
 static tree patch_if_else_statement (tree);
-static tree add_stmt_to_compound (tree, tree, tree);
 static tree add_stmt_to_block (tree, tree, tree);
 static tree patch_exit_expr (tree);
 static tree build_labeled_block (int, tree);
@@ -220,10 +220,11 @@ static tree build_try_finally_statement (int, tree, tree);
 static tree patch_try_statement (tree);
 static tree patch_synchronized_statement (tree, tree);
 static tree patch_throw_statement (tree, tree);
-static void check_thrown_exceptions (int, tree);
+static void check_thrown_exceptions (int, tree, tree);
 static int check_thrown_exceptions_do (tree);
 static void purge_unchecked_exceptions (tree);
 static bool ctors_unchecked_throws_clause_p (tree);
+static void check_concrete_throws_clauses (tree, tree, tree, tree);
 static void check_throws_clauses (tree, tree, tree);
 static void finish_method_declaration (tree);
 static tree build_super_invocation (tree);
@@ -244,9 +245,12 @@ static void start_artificial_method_body (tree);
 static void end_artificial_method_body (tree);
 static int check_method_redefinition (tree, tree);
 static int check_method_types_complete (tree);
+static bool hack_is_accessible_p (tree, tree);
 static void java_check_regular_methods (tree);
+static void check_interface_throws_clauses (tree, tree);
 static void java_check_abstract_methods (tree);
 static void unreachable_stmt_error (tree);
+static int not_accessible_field_error (tree, tree);
 static tree find_expr_with_wfl (tree);
 static void missing_return_error (tree);
 static tree build_new_array_init (int, tree);
@@ -290,7 +294,6 @@ static int pop_current_osb (struct parser_ctxt *);
 
 static tree maybe_make_nested_class_name (tree);
 static int make_nested_class_name (tree);
-static void set_nested_class_simple_name_value (tree, int);
 static void link_nested_class_to_enclosing (void);
 static tree resolve_inner_class (htab_t, tree, tree *, tree *, tree);
 static tree find_as_inner_class (tree, tree, tree);
@@ -317,12 +320,12 @@ static int outer_field_expanded_access_p (tree, tree *,
 static tree outer_field_access_fix (tree, tree, tree);
 static tree build_incomplete_class_ref (int, tree);
 static tree patch_incomplete_class_ref (tree);
-static tree create_anonymous_class (int, tree);
+static tree create_anonymous_class (tree);
 static void patch_anonymous_class (tree, tree, tree);
 static void add_inner_class_fields (tree, tree);
 
 static tree build_dot_class_method (tree);
-static tree build_dot_class_method_invocation (tree);
+static tree build_dot_class_method_invocation (tree, tree);
 static void create_new_parser_context (int);
 static tree maybe_build_class_init_for_field (tree, tree);
 
@@ -363,7 +366,7 @@ static const enum tree_code binop_lookup[19] =
   binop_lookup [((VALUE) - PLUS_TK) % ARRAY_SIZE (binop_lookup)]
 
 /* This is the end index for binary operators that can also be used
-   in compound assignements. */
+   in compound assignments. */
 #define BINOP_COMPOUND_CANDIDATES 11
 
 /* The "$L" identifier we use to create labels.  */
@@ -398,7 +401,7 @@ static GTY(()) tree package_list;
 static GTY(()) tree current_this;
 
 /* Hold a list of catch clauses list. The first element of this list is
-   the list of the catch clauses of the currently analysed try block. */
+   the list of the catch clauses of the currently analyzed try block. */
 static GTY(()) tree currently_caught_type_list;
 
 /* This holds a linked list of all the case labels for the current
@@ -904,7 +907,7 @@ class_body_declaration:
 |      constructor_declaration
 |      block                   /* Added, JDK1.1, instance initializer */
                {
-                 if ($1 != empty_stmt_node)
+                 if (!IS_EMPTY_STMT ($1))
                    {
                      TREE_CHAIN ($1) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
                      SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, $1);
@@ -1192,7 +1195,7 @@ constructor_body:
           addition (super invocation and field initialization) */
        block_begin constructor_block_end
                {
-                 BLOCK_EXPR_BODY ($2) = empty_stmt_node;
+                 BLOCK_EXPR_BODY ($2) = build_java_empty_stmt ();
                  $$ = $2;
                }
 |      block_begin explicit_constructor_invocation constructor_block_end
@@ -1349,14 +1352,8 @@ variable_initializers:
 
 /* 19.11 Production from 14: Blocks and Statements  */
 block:
-       OCB_TK CCB_TK
-               {
-                 /* Store the location of the `}' when doing xrefs */
-                 if (current_function_decl && flag_emit_xref)
-                   DECL_END_SOURCE_LINE (current_function_decl) =
-                     EXPR_WFL_ADD_COL ($2.location, 1);
-                 $$ = empty_stmt_node;
-               }
+       block_begin block_end
+               { $$ = $2; }
 |      block_begin block_statements block_end
                { $$ = $3; }
 ;
@@ -1376,7 +1373,7 @@ block_end:
                      EXPR_WFL_ADD_COL ($1.location, 1);
                  $$ = exit_block ();
                  if (!BLOCK_SUBBLOCKS ($$))
-                   BLOCK_SUBBLOCKS ($$) = empty_stmt_node;
+                   BLOCK_SUBBLOCKS ($$) = build_java_empty_stmt ();
                }
 ;
 
@@ -1452,10 +1449,10 @@ empty_statement:
                           (DECL_CONTEXT (current_function_decl)))))
 
                    {
-                     EXPR_WFL_SET_LINECOL (wfl_operator, lineno, -1);
+                     EXPR_WFL_SET_LINECOL (wfl_operator, input_line, -1);
                      parse_warning_context (wfl_operator, "An empty declaration is a deprecated feature that should not be used");
                    }
-                 $$ = empty_stmt_node;
+                 $$ = build_java_empty_stmt ();
                }
 ;
 
@@ -1489,7 +1486,7 @@ expression_statement:
                {
                  /* We have a statement. Generate a WFL around it so
                     we can debug it */
-                 $$ = build_expr_wfl ($1, input_filename, lineno, 0);
+                 $$ = build_expr_wfl ($1, input_filename, input_line, 0);
                  /* We know we have a statement, so set the debug
                      info to be eventually generate here. */
                  $$ = JAVA_MAYBE_GENERATE_DEBUG_INFO ($$);
@@ -1588,7 +1585,7 @@ switch_statement:
 switch_expression:
        SWITCH_TK OP_TK expression CP_TK
                {
-                 $$ = build (SWITCH_EXPR, NULL_TREE, $3, NULL_TREE);
+                 $$ = build (SWITCH_EXPR, NULL_TREE, $3, NULL_TREE, NULL_TREE);
                  EXPR_WFL_LINECOL ($$) = $2.location;
                }
 |      SWITCH_TK error
@@ -1636,7 +1633,7 @@ switch_label:
                }
 |      DEFAULT_TK REL_CL_TK
                {
-                 tree lab = build (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
+                 tree lab = make_node (DEFAULT_EXPR);
                  EXPR_WFL_LINECOL (lab) = $1.location;
                  java_method_add_stmt (current_function_decl, lab);
                }
@@ -1698,7 +1695,7 @@ for_statement:
                  $$ = finish_for_loop (0, NULL_TREE, $4, $6);
                  /* We have not condition, so we get rid of the EXIT_EXPR */
                  LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY ($$), 0) =
-                   empty_stmt_node;
+                   build_java_empty_stmt ();
                }
 |      for_begin SC_TK error
                {yyerror ("Invalid control expression"); RECOVER;}
@@ -1716,7 +1713,7 @@ for_statement_nsi:
                  $$ = finish_for_loop (0, NULL_TREE, $4, $6);
                  /* We have not condition, so we get rid of the EXIT_EXPR */
                  LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY ($$), 0) =
-                   empty_stmt_node;
+                   build_java_empty_stmt ();
                }
 ;
 
@@ -1747,7 +1744,7 @@ for_begin:
                }
 ;
 for_init:                      /* Can be empty */
-               { $$ = empty_stmt_node; }
+               { $$ = build_java_empty_stmt (); }
 |      statement_expression_list
                {
                  /* Init statement recorded within the previously
@@ -1765,7 +1762,7 @@ for_init:                 /* Can be empty */
 ;
 
 for_update:                    /* Can be empty */
-               {$$ = empty_stmt_node;}
+               {$$ = build_java_empty_stmt ();}
 |      statement_expression_list
                { $$ = build_debugable_stmt (BUILD_LOCATION (), $1); }
 ;
@@ -1907,15 +1904,24 @@ catch_clause_parameter:
                     formal_parameter (CCBP). The formal parameter is
                     declared initialized by the appropriate function
                     call */
-                 tree ccpb = enter_block ();
-                 tree init = build_assignment
-                   (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
-                    build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
-                 declare_local_variables (0, TREE_VALUE ($3),
-                                          build_tree_list (TREE_PURPOSE ($3),
-                                                           init));
-                 $$ = build1 (CATCH_EXPR, NULL_TREE, ccpb);
-                 EXPR_WFL_LINECOL ($$) = $1.location;
+                  tree ccpb;
+                  tree init;
+                  if ($3)
+                    {
+                      ccpb = enter_block ();
+                      init = build_assignment
+                        (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
+                         build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
+                      declare_local_variables (0, TREE_VALUE ($3),
+                                               build_tree_list 
+                                              (TREE_PURPOSE ($3), init));
+                      $$ = build1 (JAVA_CATCH_EXPR, NULL_TREE, ccpb);
+                      EXPR_WFL_LINECOL ($$) = $1.location;
+                    }
+                  else
+                    {
+                      $$ = error_mark_node;
+                    }
                }
 |      CATCH_TK error
                {yyerror ("'(' expected"); RECOVER; $$ = NULL_TREE;}
@@ -2023,12 +2029,12 @@ class_instance_creation_expression:
 
 /* Created after JDK1.1 rules originally added to
    class_instance_creation_expression, but modified to use
-   'class_type' instead of 'TypeName' (type_name) which is mentionned
+   'class_type' instead of 'TypeName' (type_name) which is mentioned
    in the documentation but doesn't exist. */
 
 anonymous_class_creation:
        NEW_TK class_type OP_TK argument_list CP_TK
-               { create_anonymous_class ($1.location, $2); }
+               { create_anonymous_class ($2); }
         class_body
                {
                  tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
@@ -2061,7 +2067,7 @@ anonymous_class_creation:
 
                }
 |      NEW_TK class_type OP_TK CP_TK
-               { create_anonymous_class ($1.location, $2); }
+               { create_anonymous_class ($2); }
         class_body
                {
                  tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
@@ -2630,8 +2636,7 @@ constant_expression:
    `dims:' rule is being used.  */
 
 static int
-pop_current_osb (ctxp)
-     struct parser_ctxt *ctxp;
+pop_current_osb (struct parser_ctxt *ctxp)
 {
   int to_return;
 
@@ -2655,8 +2660,7 @@ pop_current_osb (ctxp)
    created context becomes the current one.  */
 
 static void
-create_new_parser_context (copy_from_previous)
-    int copy_from_previous;
+create_new_parser_context (int copy_from_previous)
 {
   struct parser_ctxt *new;
 
@@ -2664,7 +2668,9 @@ create_new_parser_context (copy_from_previous)
   if (copy_from_previous)
     {
       memcpy (new, ctxp, sizeof (struct parser_ctxt));
-      new->saved_data_ctx = 1;
+      /* This flag, indicating the context saves global values,
+        should only be set by java_parser_context_save_global.  */
+      new->saved_data_ctx = 0;
     }
   else
     memset (new, 0, sizeof (struct parser_ctxt));
@@ -2676,14 +2682,13 @@ create_new_parser_context (copy_from_previous)
 /* Create a new parser context and make it the current one. */
 
 void
-java_push_parser_context ()
+java_push_parser_context (void)
 {
   create_new_parser_context (0);
 }
 
 void
-java_pop_parser_context (generate)
-     int generate;
+java_pop_parser_context (int generate)
 {
   tree current;
   struct parser_ctxt *toFree, *next;
@@ -2695,7 +2700,7 @@ java_pop_parser_context (generate)
   next = ctxp->next;
   if (next)
     {
-      lineno = ctxp->lineno;
+      input_line = ctxp->lineno;
       current_class = ctxp->class_type;
     }
 
@@ -2727,7 +2732,7 @@ java_pop_parser_context (generate)
    variables.  */
 
 void
-java_parser_context_save_global ()
+java_parser_context_save_global (void)
 {
   if (!ctxp)
     {
@@ -2738,9 +2743,12 @@ java_parser_context_save_global ()
   /* If this context already stores data, create a new one suitable
      for data storage. */
   else if (ctxp->saved_data)
-    create_new_parser_context (1);
+    {
+      create_new_parser_context (1);
+      ctxp->saved_data_ctx = 1;
+    }
 
-  ctxp->lineno = lineno;
+  ctxp->lineno = input_line;
   ctxp->class_type = current_class;
   ctxp->filename = input_filename;
   ctxp->function_decl = current_function_decl;
@@ -2751,17 +2759,13 @@ java_parser_context_save_global ()
    previous context the current one.  */
 
 void
-java_parser_context_restore_global ()
+java_parser_context_restore_global (void)
 {
-  lineno = ctxp->lineno;
+  input_line = ctxp->lineno;
   current_class = ctxp->class_type;
   input_filename = ctxp->filename;
   if (wfl_operator)
-    {
-      tree s;
-      BUILD_FILENAME_IDENTIFIER_NODE (s, input_filename);
-      EXPR_WFL_FILENAME_NODE (wfl_operator) = s;
-    }
+    EXPR_WFL_FILENAME_NODE (wfl_operator) = get_identifier (input_filename);
   current_function_decl = ctxp->function_decl;
   ctxp->saved_data = 0;
   if (ctxp->saved_data_ctx)
@@ -2773,7 +2777,7 @@ java_parser_context_restore_global ()
    classes be parsed.  */
 
 static void
-java_parser_context_suspend ()
+java_parser_context_suspend (void)
 {
   /* This makes debugging through java_debug_context easier */
   static const char *const name = "<inner buffer context>";
@@ -2799,7 +2803,7 @@ java_parser_context_suspend ()
    can resume as if no context was ever saved. */
 
 static void
-java_parser_context_resume ()
+java_parser_context_resume (void)
 {
   struct parser_ctxt *old = ctxp;             /* This one is to be discarded */
   struct parser_ctxt *saver = old->next;      /* This one contain saved info */
@@ -2813,7 +2817,7 @@ java_parser_context_resume ()
   current_class = saver->class_type;
   current_function_decl = saver->function_decl;
 
-  /* Retrive the restored context */
+  /* Retrieve the restored context */
   ctxp = restored;
 
   /* Re-installed the data for the parsing to carry on */
@@ -2826,7 +2830,7 @@ java_parser_context_resume ()
    linked.  */
 
 static void
-java_parser_context_push_initialized_field ()
+java_parser_context_push_initialized_field (void)
 {
   tree node;
 
@@ -2848,7 +2852,7 @@ java_parser_context_push_initialized_field ()
    or <clinit> functions. */
 
 static void
-java_parser_context_pop_initialized_field ()
+java_parser_context_pop_initialized_field (void)
 {
   tree stmts;
   tree class_type = TREE_TYPE (GET_CPC ());
@@ -2883,8 +2887,7 @@ java_parser_context_pop_initialized_field ()
 }
 
 static tree
-reorder_static_initialized (list)
-     tree list;
+reorder_static_initialized (tree list)
 {
   /* We have to keep things in order. The alias initializer have to
      come first, then the initialized regular field, in reverse to
@@ -2920,8 +2923,7 @@ reorder_static_initialized (list)
   {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
 
 static void
-java_debug_context_do (tab)
-     int tab;
+java_debug_context_do (int tab)
 {
   struct parser_ctxt *copy = ctxp;
   while (copy)
@@ -2949,7 +2951,7 @@ java_debug_context_do (tab)
    debugger.  */
 
 void
-java_debug_context ()
+java_debug_context (void)
 {
   java_debug_context_do (0);
 }
@@ -2964,7 +2966,7 @@ static int force_error = 0;
 
 /* Reporting an constructor invocation error.  */
 static void
-parse_ctor_invocation_error ()
+parse_ctor_invocation_error (void)
 {
   if (DECL_CONSTRUCTOR_P (current_function_decl))
     yyerror ("Constructor invocation must be first thing in a constructor");
@@ -2975,19 +2977,17 @@ parse_ctor_invocation_error ()
 /* Reporting JDK1.1 features not implemented.  */
 
 static tree
-parse_jdk1_1_error (msg)
-    const char *msg;
+parse_jdk1_1_error (const char *msg)
 {
   sorry (": `%s' JDK1.1(TM) feature", msg);
   java_error_count++;
-  return empty_stmt_node;
+  return build_java_empty_stmt ();
 }
 
 static int do_warning = 0;
 
 void
-yyerror (msg)
-     const char *msg;
+yyerror (const char *msg)
 {
   static java_lc elc;
   static int  prev_lineno;
@@ -2996,7 +2996,7 @@ yyerror (msg)
   int save_lineno;
   char *remainder, *code_from_source;
 
-  if (!force_error && prev_lineno == lineno)
+  if (!force_error && prev_lineno == input_line)
     return;
 
   /* Save current error location but report latter, when the context is
@@ -3029,8 +3029,8 @@ yyerror (msg)
       elc.line = ctxp->p_line->lineno;
     }
 
-  save_lineno = lineno;
-  prev_lineno = lineno = elc.line;
+  save_lineno = input_line;
+  prev_lineno = input_line = elc.line;
   prev_msg = msg;
 
   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
@@ -3047,14 +3047,11 @@ yyerror (msg)
      the same line. This occurs when we report an error but don't have
      a synchronization point other than ';', which
      expression_statement is the only one to take care of.  */
-  ctxp->prevent_ese = lineno = save_lineno;
+  ctxp->prevent_ese = input_line = save_lineno;
 }
 
 static void
-issue_warning_error_from_context (cl, msg, ap)
-     tree cl;
-     const char *msg;
-     va_list ap;
+issue_warning_error_from_context (tree cl, const char *msg, va_list ap)
 {
   const char *saved, *saved_input_filename;
   char buffer [4096];
@@ -3104,8 +3101,7 @@ parse_warning_context (tree cl, const char *msg, ...)
 }
 
 static tree
-find_expr_with_wfl (node)
-     tree node;
+find_expr_with_wfl (tree node)
 {
   while (node)
     {
@@ -3148,18 +3144,16 @@ find_expr_with_wfl (node)
    last line of the method the error occurs in.  */
 
 static void
-missing_return_error (method)
-     tree method;
+missing_return_error (tree method)
 {
-  EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
+  EXPR_WFL_SET_LINECOL (wfl_operator, DECL_FUNCTION_LAST_LINE (method), -2);
   parse_error_context (wfl_operator, "Missing return statement");
 }
 
 /* Issue an unreachable statement error. From NODE, find the next
    statement to report appropriately.  */
 static void
-unreachable_stmt_error (node)
-     tree node;
+unreachable_stmt_error (tree node)
 {
   /* Browse node to find the next expression node that has a WFL. Use
      the location to report the error */
@@ -3177,8 +3171,20 @@ unreachable_stmt_error (node)
     abort ();
 }
 
+static int
+not_accessible_field_error (tree wfl, tree decl)
+{
+  parse_error_context 
+    (wfl, "Can't access %s field `%s.%s' from `%s'",
+     accessibility_string (get_access_flags_from_decl (decl)),
+     GET_TYPE_NAME (DECL_CONTEXT (decl)),
+     IDENTIFIER_POINTER (DECL_NAME (decl)),
+     IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
+  return 1;
+}
+
 int
-java_report_errors ()
+java_report_errors (void)
 {
   if (java_error_count)
     fprintf (stderr, "%d error%s",
@@ -3192,8 +3198,7 @@ java_report_errors ()
 }
 
 static char *
-java_accstring_lookup (flags)
-     int flags;
+java_accstring_lookup (int flags)
 {
   static char buffer [80];
 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
@@ -3217,13 +3222,27 @@ java_accstring_lookup (flags)
 #undef COPY_RETURN
 }
 
+/* Returns a string denoting the accessibility of a class or a member as
+   indicated by FLAGS.  We need a separate function from
+   java_accstring_lookup, as the latter can return spurious "static", etc.
+   if package-private access is defined (in which case none of the
+   relevant access control bits in FLAGS is set).  */
+
+static const char *
+accessibility_string (int flags)
+{
+  if (flags & ACC_PRIVATE) return "private";
+  if (flags & ACC_PROTECTED) return "protected";
+  if (flags & ACC_PUBLIC) return "public";
+
+  return "package-private";
+}
+
 /* Issuing error messages upon redefinition of classes, interfaces or
    variables. */
 
 static void
-classitf_redefinition_error (context, id, decl, cl)
-     const char *context;
-     tree id, decl, cl;
+classitf_redefinition_error (const char *context, tree id, tree decl, tree cl)
 {
   parse_error_context (cl, "%s `%s' already defined in %s:%d",
                       context, IDENTIFIER_POINTER (id),
@@ -3232,9 +3251,7 @@ classitf_redefinition_error (context, id, decl, cl)
 }
 
 static void
-variable_redefinition_error (context, name, type, line)
-     tree context, name, type;
-     int line;
+variable_redefinition_error (tree context, tree name, tree type, int line)
 {
   const char *type_name;
 
@@ -3256,9 +3273,7 @@ variable_redefinition_error (context, name, type, line)
    the node pointed to by TRIMMED unless TRIMMED is null.  */
 
 static int
-build_type_name_from_array_name (aname, trimmed)
-     tree aname;
-     tree *trimmed;
+build_type_name_from_array_name (tree aname, tree *trimmed)
 {
   const char *name = IDENTIFIER_POINTER (aname);
   int len = IDENTIFIER_LENGTH (aname);
@@ -3273,8 +3288,7 @@ build_type_name_from_array_name (aname, trimmed)
 }
 
 static tree
-build_array_from_name (type, type_wfl, name, ret_name)
-     tree type, type_wfl, name, *ret_name;
+build_array_from_name (tree type, tree type_wfl, tree name, tree *ret_name)
 {
   int more_dims = 0;
 
@@ -3326,8 +3340,7 @@ build_array_from_name (type, type_wfl, name, ret_name)
    identifier. */
 
 static tree
-build_unresolved_array_type (type_or_wfl)
-     tree type_or_wfl;
+build_unresolved_array_type (tree type_or_wfl)
 {
   const char *ptr;
   tree wfl;
@@ -3353,8 +3366,7 @@ build_unresolved_array_type (type_or_wfl)
 }
 
 static void
-parser_add_interface (class_decl, interface_decl, wfl)
-     tree class_decl, interface_decl, wfl;
+parser_add_interface (tree class_decl, tree interface_decl, tree wfl)
 {
   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
     parse_error_context (wfl, "Interface `%s' repeated",
@@ -3365,9 +3377,8 @@ parser_add_interface (class_decl, interface_decl, wfl)
    encountered. TAG is 0 for a class, 1 for an interface.  */
 
 static int
-check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
-     int is_interface, flags;
-     tree raw_name, qualified_name, decl, cl;
+check_class_interface_creation (int is_interface, int flags, tree raw_name,
+                               tree qualified_name, tree decl, tree cl)
 {
   tree node;
   int sca = 0;                 /* Static class allowed */
@@ -3483,8 +3494,7 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d
 /* Construct a nested class name.  If the final component starts with
    a digit, return true.  Otherwise return false.  */
 static int
-make_nested_class_name (cpc_list)
-     tree cpc_list;
+make_nested_class_name (tree cpc_list)
 {
   tree name;
 
@@ -3507,8 +3517,7 @@ make_nested_class_name (cpc_list)
 /* Can't redefine a class already defined in an earlier scope. */
 
 static int
-check_inner_class_redefinition (raw_name, cl)
-     tree raw_name, cl;
+check_inner_class_redefinition (tree raw_name, tree cl)
 {
   tree scope_list;
 
@@ -3528,9 +3537,8 @@ check_inner_class_redefinition (raw_name, cl)
    we remember ENCLOSING and SUPER.  */
 
 static tree
-resolve_inner_class (circularity_hash, cl, enclosing, super, class_type)
-     htab_t circularity_hash;
-     tree cl, *enclosing, *super, class_type;
+resolve_inner_class (htab_t circularity_hash, tree cl, tree *enclosing,
+                    tree *super, tree class_type)
 {
   tree local_enclosing = *enclosing;
   tree local_super = NULL_TREE;
@@ -3554,9 +3562,16 @@ resolve_inner_class (circularity_hash, cl, enclosing, super, class_type)
            return decl;
        }
 
-      /* Now go to the upper classes, bail out if necessary. We will
+      /* Now go to the upper classes, bail out if necessary.  We will
         analyze the returned SUPER and act accordingly (see
-        do_resolve_class.) */
+        do_resolve_class).  */
+      if (JPRIMITIVE_TYPE_P (TREE_TYPE (local_enclosing))
+         || TREE_TYPE (local_enclosing) == void_type_node)
+       {
+         parse_error_context (cl, "Qualifier must be a reference");
+         local_enclosing = NULL_TREE;
+         break;
+       }
       local_super = CLASSTYPE_SUPER (TREE_TYPE (local_enclosing));
       if (!local_super || local_super == object_type_node)
         break;
@@ -3593,8 +3608,7 @@ resolve_inner_class (circularity_hash, cl, enclosing, super, class_type)
    qualified. */
 
 static tree
-find_as_inner_class (enclosing, name, cl)
-     tree enclosing, name, cl;
+find_as_inner_class (tree enclosing, tree name, tree cl)
 {
   tree qual, to_return;
   if (!enclosing)
@@ -3647,8 +3661,7 @@ find_as_inner_class (enclosing, name, cl)
    through. */
 
 static tree
-find_as_inner_class_do (qual, enclosing)
-     tree qual, enclosing;
+find_as_inner_class_do (tree qual, tree enclosing)
 {
   if (!qual)
     return NULL_TREE;
@@ -3674,23 +3687,8 @@ find_as_inner_class_do (qual, enclosing)
   return (!qual && enclosing ? enclosing : NULL_TREE);
 }
 
-/* Reach all inner classes and tie their unqualified name to a
-   DECL. */
-
 static void
-set_nested_class_simple_name_value (outer, set)
-     tree outer;
-     int set;
-{
-  tree l;
-
-  for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
-    IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
-                                               TREE_PURPOSE (l) : NULL_TREE);
-}
-
-static void
-link_nested_class_to_enclosing ()
+link_nested_class_to_enclosing (void)
 {
   if (GET_ENCLOSING_CPC ())
     {
@@ -3702,8 +3700,7 @@ link_nested_class_to_enclosing ()
 }
 
 static tree
-maybe_make_nested_class_name (name)
-     tree name;
+maybe_make_nested_class_name (tree name)
 {
   tree id = NULL_TREE;
 
@@ -3737,15 +3734,15 @@ maybe_make_nested_class_name (name)
    line CL and do other maintenance things.  */
 
 static tree
-maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
-     tree decl, raw_name, qualified_name, cl;
+maybe_create_class_interface_decl (tree decl, tree raw_name,
+                                  tree qualified_name, tree cl)
 {
   if (!decl)
     decl = push_class (make_class (), qualified_name);
 
   /* Take care of the file and line business */
   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
-  /* If we're emiting xrefs, store the line/col number information */
+  /* If we're emitting xrefs, store the line/col number information */
   if (flag_emit_xref)
     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
   else
@@ -3775,8 +3772,7 @@ maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
 }
 
 static void
-add_superinterfaces (decl, interface_list)
-     tree decl, interface_list;
+add_superinterfaces (tree decl, tree interface_list)
 {
   tree node;
   /* Superinterface(s): if present and defined, parser_check_super_interface ()
@@ -3805,9 +3801,7 @@ add_superinterfaces (decl, interface_list)
    interface's decl in pass 2.  */
 
 static tree
-create_interface (flags, id, super)
-     int flags;
-     tree id, super;
+create_interface (int flags, tree id, tree super)
 {
   tree raw_name = EXPR_WFL_NODE (id);
   tree q_name = parser_qualified_classname (raw_name);
@@ -3852,6 +3846,13 @@ create_interface (flags, id, super)
   /* Create a new decl if DECL is NULL, otherwise fix it */
   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
 
+  /* Interfaces are always abstract. */
+  flags |= ACC_ABSTRACT;
+
+  /* Inner interfaces are always static.  */
+  if (INNER_CLASS_DECL_P (decl))
+    flags |= ACC_STATIC;
+
   /* Set super info and mark the class a complete */
   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
                  object_type_node, ctxp->interface_number);
@@ -3859,6 +3860,9 @@ create_interface (flags, id, super)
   CLASS_COMPLETE_P (decl) = 1;
   add_superinterfaces (decl, super);
 
+  /* Eventually sets the @deprecated tag flag */
+  CHECK_DEPRECATED (decl);
+
   return decl;
 }
 
@@ -3866,8 +3870,7 @@ create_interface (flags, id, super)
    DEP.  */
 
 static void
-patch_anonymous_class (type_decl, class_decl, wfl)
-    tree type_decl, class_decl, wfl;
+patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
 {
   tree class = TREE_TYPE (class_decl);
   tree type =  TREE_TYPE (type_decl);
@@ -3876,16 +3879,24 @@ patch_anonymous_class (type_decl, class_decl, wfl)
   /* If it's an interface, implement it */
   if (CLASS_INTERFACE (type_decl))
     {
-      tree s_binfo;
-      int length;
-
       if (parser_check_super_interface (type_decl, class_decl, wfl))
        return;
 
-      s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
-      length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
-      TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
-      TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
+      if (VEC_space (tree, BINFO_BASE_BINFOS (binfo), 1))
+       {
+          /* Extend the binfo - by reallocating and copying it. */
+         tree new_binfo;
+         tree base_binfo;
+         int i;
+         
+         new_binfo = make_tree_binfo ((BINFO_N_BASE_BINFOS (binfo) + 1) * 2);
+         for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+           BINFO_BASE_APPEND (new_binfo, base_binfo);
+         CLASS_HAS_SUPER_FLAG (new_binfo) = CLASS_HAS_SUPER_FLAG (binfo);
+         BINFO_VTABLE (new_binfo) = BINFO_VTABLE (binfo);
+         TYPE_BINFO (class) = new_binfo;
+       }
+      
       /* And add the interface */
       parser_add_interface (class_decl, type_decl, wfl);
     }
@@ -3894,14 +3905,15 @@ patch_anonymous_class (type_decl, class_decl, wfl)
     {
       if (parser_check_super (type_decl, class_decl, wfl))
        return;
-      BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
+      BINFO_TYPE (BINFO_BASE_BINFO (binfo, 0)) = type;
     }
 }
 
+/* Create an anonymous class which extends/implements TYPE_NAME, and return
+   its decl.  */
+
 static tree
-create_anonymous_class (location, type_name)
-    int location;
-    tree type_name;
+create_anonymous_class (tree type_name)
 {
   char buffer [80];
   tree super = NULL_TREE, itf = NULL_TREE;
@@ -3910,13 +3922,13 @@ create_anonymous_class (location, type_name)
   /* The unqualified name of the anonymous class. It's just a number. */
   sprintf (buffer, "%d", anonymous_class_counter++);
   id = build_wfl_node (get_identifier (buffer));
-  EXPR_WFL_LINECOL (id) = location;
+  EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (type_name);
 
   /* We know about the type to extend/implement. We go ahead */
   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
     {
       /* Create a class which either implements on extends the designated
-        class. The class bears an innacessible name. */
+        class. The class bears an inaccessible name. */
       if (CLASS_INTERFACE (type_decl))
        {
          /* It's OK to modify it here. It's been already used and
@@ -3943,9 +3955,7 @@ create_anonymous_class (location, type_name)
    interface's decl in pass 2.  */
 
 static tree
-create_class (flags, id, super, interfaces)
-     int flags;
-     tree id, super, interfaces;
+create_class (int flags, tree id, tree super, tree interfaces)
 {
   tree raw_name = EXPR_WFL_NODE (id);
   tree class_id, decl;
@@ -3995,10 +4005,10 @@ create_class (flags, id, super, interfaces)
   /* If SUPER exists, use it, otherwise use Object */
   if (super)
     {
-      /* Can't extend java.lang.Object */
+      /* java.lang.Object can't extend anything.  */
       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
        {
-         parse_error_context (id, "Can't extend `java.lang.Object'");
+         parse_error_context (id, "`java.lang.Object' can't extend anything");
          return NULL_TREE;
        }
 
@@ -4025,9 +4035,14 @@ create_class (flags, id, super, interfaces)
   CLASS_COMPLETE_P (decl) = 1;
   add_superinterfaces (decl, interfaces);
 
+  /* TYPE_VFIELD' is a compiler-generated field used to point to
+     virtual function tables.  In gcj, every class has a common base
+     virtual function table in java.lang.object.  */
+  TYPE_VFIELD (TREE_TYPE (decl)) = TYPE_VFIELD (object_type_node);
+
   /* Add the private this$<n> field, Replicate final locals still in
      scope as private final fields mangled like val$<local_name>.
-     This doesn't not occur for top level (static) inner classes. */
+     This does not occur for top level (static) inner classes. */
   if (PURE_INNER_CLASS_DECL_P (decl))
     add_inner_class_fields (decl, current_function_decl);
 
@@ -4051,8 +4066,7 @@ create_class (flags, id, super, interfaces)
    parser context if necessary.  */
 
 static void
-end_class_declaration (resume)
-     int resume;
+end_class_declaration (int resume)
 {
   /* If an error occurred, context weren't pushed and won't need to be
      popped by a resume. */
@@ -4075,9 +4089,7 @@ end_class_declaration (resume)
 }
 
 static void
-add_inner_class_fields (class_decl, fct_decl)
-     tree class_decl;
-     tree fct_decl;
+add_inner_class_fields (tree class_decl, tree fct_decl)
 {
   tree block, marker, f;
 
@@ -4122,7 +4134,7 @@ add_inner_class_fields (class_decl, fct_decl)
             methods first, then finit$ to get a picture of what's
             used.  It works with the exception that we would have to
             go back on all constructor invoked in regular methods to
-            have their invokation reworked (to include the right amount
+            have their invocation reworked (to include the right amount
             of alias initializer parameters.)
 
             The only real way around, I think, is a first pass to
@@ -4132,10 +4144,10 @@ add_inner_class_fields (class_decl, fct_decl)
 
             On the other hand, it only affect local inner classes,
             whose constructors (and finit$ call) will be featuring
-            unecessary arguments. It's easy for a developper to keep
+            unnecessary arguments. It's easy for a developer to keep
             this number of parameter down by using the `final'
             keyword only when necessary. For the time being, we can
-            issue a warning on unecessary finals. FIXME */
+            issue a warning on unnecessary finals. FIXME */
          init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
                                   wfl, init);
 
@@ -4153,7 +4165,7 @@ add_inner_class_fields (class_decl, fct_decl)
     return;
 
   /* If we ever registered an alias field, insert and marker to
-     remeber where the list ends. The second part of the list (the one
+     remember where the list ends. The second part of the list (the one
      featuring initialized fields) so it can be later reversed to
      enforce 8.5. The marker will be removed during that operation. */
   marker = build_tree_list (NULL_TREE, NULL_TREE);
@@ -4165,9 +4177,7 @@ add_inner_class_fields (class_decl, fct_decl)
    can't set the CLASS_LOADED_P flag */
 
 static tree
-find_field (class, name)
-     tree class;
-     tree name;
+find_field (tree class, tree name)
 {
   tree decl;
   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
@@ -4182,8 +4192,7 @@ find_field (class, name)
    of CLASS */
 
 static tree
-lookup_field_wrapper (class, name)
-     tree class, name;
+lookup_field_wrapper (tree class, tree name)
 {
   tree type = class;
   tree decl = NULL_TREE;
@@ -4222,8 +4231,7 @@ lookup_field_wrapper (class, name)
    otherwise.  */
 
 static int
-duplicate_declaration_error_p (new_field_name, new_type, cl)
-     tree new_field_name, new_type, cl;
+duplicate_declaration_error_p (tree new_field_name, tree new_type, tree cl)
 {
   /* This might be modified to work with method decl as well */
   tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
@@ -4258,13 +4266,11 @@ duplicate_declaration_error_p (new_field_name, new_type, cl)
    be later resolved in java_complete_class () */
 
 static void
-register_fields (flags, type, variable_list)
-     int flags;
-     tree type, variable_list;
+register_fields (int flags, tree type, tree variable_list)
 {
   tree current, saved_type;
   tree class_type = NULL_TREE;
-  int saved_lineno = lineno;
+  int saved_lineno = input_line;
   int must_chain = 0;
   tree wfl = NULL_TREE;
 
@@ -4331,14 +4337,14 @@ register_fields (flags, type, variable_list)
       if (duplicate_declaration_error_p (current_name, real_type, cl))
        continue;
 
-      /* Set lineno to the line the field was found and create a
+      /* Set input_line to the line the field was found and create a
          declaration for it. Eventually sets the @deprecated tag flag. */
       if (flag_emit_xref)
-       lineno = EXPR_WFL_LINECOL (cl);
+       input_line = EXPR_WFL_LINECOL (cl);
       else
-       lineno = EXPR_WFL_LINENO (cl);
+       input_line = EXPR_WFL_LINENO (cl);
       field_decl = add_field (class_type, current_name, real_type, flags);
-      CHECK_DEPRECATED (field_decl);
+      CHECK_DEPRECATED_NO_RESET (field_decl);
 
       /* If the field denotes a final instance variable, then we
         allocate a LANG_DECL_SPECIFIC part to keep track of its
@@ -4396,7 +4402,9 @@ register_fields (flags, type, variable_list)
          DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
        }
     }
-  lineno = saved_lineno;
+
+  CLEAR_DEPRECATED;
+  input_line = saved_lineno;
 }
 
 /* Generate finit$, using the list of initialized fields to populate
@@ -4405,8 +4413,7 @@ register_fields (flags, type, variable_list)
    local(s).  */
 
 static tree
-generate_finit (class_type)
-     tree class_type;
+generate_finit (tree class_type)
 {
   int count = 0;
   tree list = TYPE_FINIT_STMT_LIST (class_type);
@@ -4440,8 +4447,7 @@ generate_finit (class_type)
    statements in a try/catch/rethrow sequence.  */
 
 static tree
-generate_instinit (class_type)
-     tree class_type;
+generate_instinit (tree class_type)
 {
   tree current;
   tree compound = NULL_TREE;
@@ -4483,8 +4489,7 @@ generate_instinit (class_type)
 
 /* FIXME */
 static tree
-build_instinit_invocation (class_type)
-     tree class_type;
+build_instinit_invocation (tree class_type)
 {
   tree to_return = NULL_TREE;
 
@@ -4499,7 +4504,7 @@ build_instinit_invocation (class_type)
   return to_return;
 }
 
-/* Shared accros method_declarator and method_header to remember the
+/* Shared across method_declarator and method_header to remember the
    patch stage that was reached during the declaration of the method.
    A method DECL is built differently is there is no patch
    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
@@ -4514,9 +4519,7 @@ static int patch_stage;
    with a constructor.  */
 
 static tree
-method_header (flags, type, mdecl, throws)
-     int flags;
-     tree type, mdecl, throws;
+method_header (int flags, tree type, tree mdecl, tree throws)
 {
   tree type_wfl = NULL_TREE;
   tree meth_name = NULL_TREE;
@@ -4557,6 +4560,18 @@ method_header (flags, type, mdecl, throws)
           IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
     }
 
+  /* A native method can't be strictfp.  */
+  if ((flags & ACC_NATIVE) && (flags & ACC_STRICT))
+    parse_error_context (id, "native method `%s' can't be strictfp",
+                        IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
+  /* No such thing as a transient or volatile method.  */
+  if ((flags & ACC_TRANSIENT))
+    parse_error_context (id, "method `%s' can't be transient",
+                        IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
+  if ((flags & ACC_VOLATILE))
+    parse_error_context (id, "method `%s' can't be volatile",
+                        IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
+
   /* Things to be checked when declaring a constructor */
   if (!type)
     {
@@ -4641,11 +4656,11 @@ method_header (flags, type, mdecl, throws)
   else
     TREE_TYPE (meth) = type;
 
-  saved_lineno = lineno;
+  saved_lineno = input_line;
   /* When defining an abstract or interface method, the curly
      bracket at level 1 doesn't exist because there is no function
      body */
-  lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
+  input_line = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
            EXPR_WFL_LINENO (id));
 
   /* Remember the original argument list */
@@ -4679,7 +4694,7 @@ method_header (flags, type, mdecl, throws)
   /* Register the parameter number and re-install the current line
      number */
   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
-  lineno = saved_lineno;
+  input_line = saved_lineno;
 
   /* Register exception specified by the `throws' keyword for
      resolution and set the method decl appropriate field to the list.
@@ -4726,8 +4741,7 @@ method_header (flags, type, mdecl, throws)
 }
 
 static void
-fix_method_argument_names (orig_arg, meth)
-    tree orig_arg, meth;
+fix_method_argument_names (tree orig_arg, tree meth)
 {
   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
@@ -4746,8 +4760,7 @@ fix_method_argument_names (orig_arg, meth)
 /* Complete the method declaration with METHOD_BODY.  */
 
 static void
-finish_method_declaration (method_body)
-     tree method_body;
+finish_method_declaration (tree method_body)
 {
   int flags;
 
@@ -4790,7 +4803,7 @@ finish_method_declaration (method_body)
   /* Merge last line of the function with first line, directly in the
      function decl. It will be used to emit correct debug info. */
   if (!flag_emit_xref)
-    DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
+    DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
 
   /* Since function's argument's list are shared, reset the
      ARG_FINAL_P parameter that might have been set on some of this
@@ -4805,8 +4818,7 @@ finish_method_declaration (method_body)
 /* Build a an error message for constructor circularity errors.  */
 
 static char *
-constructor_circularity_msg (from, to)
-     tree from, to;
+constructor_circularity_msg (tree from, tree to)
 {
   static char string [4096];
   char *t = xstrdup (lang_printable_name (from, 0));
@@ -4820,8 +4832,7 @@ constructor_circularity_msg (from, to)
 
 static GTY(()) tree vcc_list;
 static int
-verify_constructor_circularity (meth, current)
-     tree meth, current;
+verify_constructor_circularity (tree meth, tree current)
 {
   tree c;
 
@@ -4865,8 +4876,7 @@ verify_constructor_circularity (meth, current)
 /* Check modifiers that can be declared but exclusively */
 
 static void
-check_modifiers_consistency (flags)
-     int flags;
+check_modifiers_consistency (int flags)
 {
   int acc_count = 0;
   tree cl = NULL_TREE;
@@ -4890,8 +4900,7 @@ check_modifiers_consistency (flags)
 /* Check the methode header METH for abstract specifics features */
 
 static void
-check_abstract_method_header (meth)
-     tree meth;
+check_abstract_method_header (tree meth)
 {
   int flags = get_access_flags_from_decl (meth);
 
@@ -4912,8 +4921,7 @@ check_abstract_method_header (meth)
    incomplete types.  */
 
 static tree
-method_declarator (id, list)
-     tree id, list;
+method_declarator (tree id, tree list)
 {
   tree arg_types = NULL_TREE, current, node;
   tree meth = make_node (FUNCTION_TYPE);
@@ -4996,7 +5004,7 @@ method_declarator (id, list)
 
       /* The argument node: a name and a (possibly) incomplete type.  */
       arg_node = build_tree_list (name, real_type);
-      /* Remeber arguments declared final. */
+      /* Remember arguments declared final. */
       ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
 
       if (jdep)
@@ -5010,10 +5018,7 @@ method_declarator (id, list)
 }
 
 static int
-unresolved_type_p (wfl, returned)
-     tree wfl;
-     tree *returned;
-
+unresolved_type_p (tree wfl, tree *returned)
 {
   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
     {
@@ -5038,8 +5043,7 @@ unresolved_type_p (wfl, returned)
    qualification from the current package definition. */
 
 static tree
-parser_qualified_classname (name)
-     tree name;
+parser_qualified_classname (tree name)
 {
   tree nested_class_name;
 
@@ -5056,8 +5060,7 @@ parser_qualified_classname (name)
    everything is OK.  */
 
 static int
-parser_check_super_interface (super_decl, this_decl, this_wfl)
-     tree super_decl, this_decl, this_wfl;
+parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl)
 {
   tree super_type = TREE_TYPE (super_decl);
 
@@ -5078,7 +5081,7 @@ parser_check_super_interface (super_decl, this_decl, this_wfl)
      access rules (6.6.1). */
   if (! INNER_CLASS_P (super_type)
       && check_pkg_class_access (DECL_NAME (super_decl),
-                                lookup_cl (this_decl), true))
+                                NULL_TREE, true, this_decl))
     return 1;
 
   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
@@ -5088,11 +5091,10 @@ parser_check_super_interface (super_decl, this_decl, this_wfl)
 }
 
 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
-   0 if everthing is OK.  */
+   0 if everything is OK.  */
 
 static int
-parser_check_super (super_decl, this_decl, wfl)
-     tree super_decl, this_decl, wfl;
+parser_check_super (tree super_decl, tree this_decl, tree wfl)
 {
   tree super_type = TREE_TYPE (super_decl);
 
@@ -5117,7 +5119,7 @@ parser_check_super (super_decl, this_decl, wfl)
   /* Check top-level class scope. Inner classes are subject to member access
      rules (6.6.1). */
   if (! INNER_CLASS_P (super_type)
-      && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true)))
+      && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true, NULL_TREE)))
     return 1;
 
   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
@@ -5130,8 +5132,7 @@ parser_check_super (super_decl, this_decl, wfl)
    CTXP list of type dependency list.  */
 
 static void
-create_jdep_list (ctxp)
-     struct parser_ctxt *ctxp;
+create_jdep_list (struct parser_ctxt *ctxp)
 {
   jdeplist *new = xmalloc (sizeof (jdeplist));
   new->first = new->last = NULL;
@@ -5140,10 +5141,9 @@ create_jdep_list (ctxp)
 }
 
 static jdeplist *
-reverse_jdep_list (ctxp)
-     struct parser_ctxt *ctxp;
+reverse_jdep_list (struct parser_ctxt *ctxp)
 {
-  register jdeplist *prev = NULL, *current, *next;
+  jdeplist *prev = NULL, *current, *next;
   for (current = ctxp->classd_list; current; current = next)
     {
       next = current->next;
@@ -5158,8 +5158,7 @@ reverse_jdep_list (ctxp)
    registered again. */
 
 static tree
-obtain_incomplete_type (type_name)
-     tree type_name;
+obtain_incomplete_type (tree type_name)
 {
   tree ptr = NULL_TREE, name;
 
@@ -5184,9 +5183,7 @@ obtain_incomplete_type (type_name)
    manner.  */
 
 static tree
-register_incomplete_type (kind, wfl, decl, ptr)
-     int kind;
-     tree wfl, decl, ptr;
+register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
 {
   jdep *new = xmalloc (sizeof (jdep));
 
@@ -5201,12 +5198,9 @@ register_incomplete_type (kind, wfl, decl, ptr)
   JDEP_MISC (new) = NULL_TREE;
   /* For some dependencies, set the enclosing class of the current
      class to be the enclosing context */
-  if ((kind == JDEP_INTERFACE  || kind == JDEP_ANONYMOUS)
+  if ((kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS || kind == JDEP_SUPER)
       && GET_ENCLOSING_CPC ())
     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
-  else if (kind == JDEP_SUPER)
-    JDEP_ENCLOSING (new) = (GET_ENCLOSING_CPC () ?
-                           TREE_VALUE (GET_ENCLOSING_CPC ()) : NULL_TREE);
   else
     JDEP_ENCLOSING (new) = GET_CPC ();
   JDEP_GET_PATCH (new) = (tree *)NULL;
@@ -5225,27 +5219,20 @@ register_incomplete_type (kind, wfl, decl, ptr)
    otherwise.  */
 
 static tree
-check_inner_circular_reference (source, target)
-     tree source;
-     tree target;
+check_inner_circular_reference (tree source, tree target)
 {
-  tree basetype_vec = TYPE_BINFO_BASETYPES (source);
+  tree base_binfo;
   tree ctx, cl;
   int i;
 
-  if (!basetype_vec)
-    return NULL_TREE;
-
-  for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (source), i, base_binfo); i++)
     {
       tree su;
 
       /* We can end up with a NULL_TREE or an incomplete type here if
         we encountered previous type resolution errors. It's safe to
         simply ignore these cases.  */
-      if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
-       continue;
-      su = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+      su = BINFO_TYPE (base_binfo);
       if (INCOMPLETE_TYPE_P (su))
        continue;
 
@@ -5273,13 +5260,12 @@ check_inner_circular_reference (source, target)
    otherwise. TYPE can be an interface or a class.   */
 
 static tree
-check_circular_reference (type)
-     tree type;
+check_circular_reference (tree type)
 {
-  tree basetype_vec = TYPE_BINFO_BASETYPES (type);
+  tree base_binfo;
   int i;
 
-  if (!basetype_vec)
+  if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
     return NULL_TREE;
 
   if (! CLASS_INTERFACE (TYPE_NAME (type)))
@@ -5289,18 +5275,17 @@ check_circular_reference (type)
       return NULL_TREE;
     }
 
-  for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo); i++)
     {
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
-      if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
-         && interface_of_p (type, BINFO_TYPE (vec_elt)))
-       return lookup_cl (TYPE_NAME (BINFO_TYPE (vec_elt)));
+      if (BINFO_TYPE (base_binfo) != object_type_node
+         && interface_of_p (type, BINFO_TYPE (base_binfo)))
+       return lookup_cl (TYPE_NAME (BINFO_TYPE (base_binfo)));
     }
   return NULL_TREE;
 }
 
 void
-java_check_circular_reference ()
+java_check_circular_reference (void)
 {
   tree current;
   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
@@ -5326,10 +5311,8 @@ java_check_circular_reference ()
    finit$.  */
 
 static tree
-build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
-    int mode;
-    tree class_type, parm;
-    int *artificial;
+build_alias_initializer_parameter_list (int mode, tree class_type, tree parm,
+                                       int *artificial)
 {
   tree field;
   tree additional_parms = NULL_TREE;
@@ -5373,7 +5356,7 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
            break;
 
          case AIPL_FUNCTION_CTOR_INVOCATION:
-           /* There are two case: the constructor invokation happends
+           /* There are two case: the constructor invocation happens
               outside the local inner, in which case, locales from the outer
               context are directly used.
 
@@ -5407,13 +5390,13 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
    enforced. This is the case for anonymous classes.  */
 
 static tree
-craft_constructor (class_decl, args)
-     tree class_decl, args;
+craft_constructor (tree class_decl, tree args)
 {
   tree class_type = TREE_TYPE (class_decl);
   tree parm = NULL_TREE;
-  int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
-              ACC_PUBLIC : 0);
+  /* Inherit access flags for the constructor from its enclosing class. */
+  int valid_ctor_flags = ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE;
+  int flags = (get_access_flags_from_decl (class_decl) & valid_ctor_flags);
   int i = 0, artificial = 0;
   tree decl, ctor_name;
   char buffer [80];
@@ -5455,6 +5438,7 @@ craft_constructor (class_decl, args)
   /* Now, mark the artificial parameters. */
   DECL_FUNCTION_NAP (decl) = artificial;
   DECL_FUNCTION_SYNTHETIC_CTOR (decl) = DECL_CONSTRUCTOR_P (decl) = 1;
+  DECL_INLINE (decl) = 1;
   return decl;
 }
 
@@ -5466,7 +5450,7 @@ craft_constructor (class_decl, args)
    compilation triggered this one to be simply loaded.  */
 
 void
-java_fix_constructors ()
+java_fix_constructors (void)
 {
   tree current;
 
@@ -5479,7 +5463,7 @@ java_fix_constructors ()
       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
        continue;
 
-      current_class = class_type;
+      output_class = current_class = class_type;
       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
        {
          if (DECL_CONSTRUCTOR_P (decl))
@@ -5496,27 +5480,23 @@ java_fix_constructors ()
 }
 
 /* safe_layout_class just makes sure that we can load a class without
-   disrupting the current_class, input_file, lineno, etc, information
+   disrupting the current_class, input_file, input_line, etc, information
    about the class processed currently.  */
 
 void
-safe_layout_class (class)
-     tree class;
+safe_layout_class (tree class)
 {
   tree save_current_class = current_class;
-  const char *save_input_filename = input_filename;
-  int save_lineno = lineno;
+  location_t save_location = input_location;
 
   layout_class (class);
 
   current_class = save_current_class;
-  input_filename = save_input_filename;
-  lineno = save_lineno;
+  input_location = save_location;
 }
 
 static tree
-jdep_resolve_class (dep)
-     jdep *dep;
+jdep_resolve_class (jdep *dep)
 {
   tree decl;
 
@@ -5527,11 +5507,15 @@ jdep_resolve_class (dep)
       decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
                            JDEP_DECL (dep), JDEP_WFL (dep));
       JDEP_RESOLVED (dep, decl);
+      /* If there is no WFL, that's ok.  We generate this warning
+        elsewhere.  */
+      if (decl && JDEP_WFL (dep) != NULL_TREE)
+       check_deprecation (JDEP_WFL (dep), decl);
     }
 
   if (!decl)
     complete_class_report_errors (dep);
-  else if (PURE_INNER_CLASS_DECL_P (decl))
+  else if (INNER_CLASS_DECL_P (decl))
     {
       tree inner = TREE_TYPE (decl);
       if (! CLASS_LOADED_P (inner))
@@ -5548,7 +5532,7 @@ jdep_resolve_class (dep)
 /* Complete unsatisfied class declaration and their dependencies */
 
 void
-java_complete_class ()
+java_complete_class (void)
 {
   tree cclass;
   jdeplist *cclassd;
@@ -5587,8 +5571,9 @@ java_complete_class ()
              /* Simply patch super */
              if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
                continue;
-             BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
-               (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
+             BINFO_TYPE (BINFO_BASE_BINFO
+                         (TYPE_BINFO (TREE_TYPE (JDEP_DECL (dep))), 0))
+               = TREE_TYPE (decl);
              break;
 
            case JDEP_FIELD:
@@ -5696,8 +5681,7 @@ java_complete_class ()
    array.  */
 
 static tree
-resolve_class (enclosing, class_type, decl, cl)
-     tree enclosing, class_type, decl, cl;
+resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
 {
   tree tname = TYPE_NAME (class_type);
   tree resolved_type = TREE_TYPE (class_type);
@@ -5740,15 +5724,14 @@ resolve_class (enclosing, class_type, decl, cl)
   return resolved_type_decl;
 }
 
-/* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
-   are used to report error messages. Do not try to replace TYPE_NAME
-   (class_type) by a variable, since it is changed by
-   find_in_imports{_on_demand} and (but it doesn't really matter)
-   qualify_and_find.  */
+/* Effectively perform the resolution of class CLASS_TYPE.  DECL or CL
+   are used to report error messages; CL must either be NULL_TREE or a
+   WFL wrapping a class.  Do not try to replace TYPE_NAME (class_type)
+   by a variable, since it is changed by find_in_imports{_on_demand}
+   and (but it doesn't really matter) qualify_and_find.  */
 
 tree
-do_resolve_class (enclosing, class_type, decl, cl)
-     tree enclosing, class_type, decl, cl;
+do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
 {
   tree new_class_decl = NULL_TREE, super = NULL_TREE;
   tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE;
@@ -5762,14 +5745,16 @@ do_resolve_class (enclosing, class_type, decl, cl)
         class and then treat Id as a member type.  If we can't find Q
         as a class then we fall through.  */
       tree q, left, left_type, right;
-      breakdown_qualified (&left, &right, TYPE_NAME (class_type));
-      BUILD_PTR_FROM_NAME (left_type, left);
-      q = do_resolve_class (enclosing, left_type, decl, cl);
-      if (q)
+      if (split_qualified_name (&left, &right, TYPE_NAME (class_type)) == 0)
        {
-         enclosing = q;
-         saved_enclosing_type = TREE_TYPE (q);
-         BUILD_PTR_FROM_NAME (class_type, right);
+         BUILD_PTR_FROM_NAME (left_type, left);
+         q = do_resolve_class (enclosing, left_type, decl, cl);
+         if (q)
+           {
+             enclosing = q;
+             saved_enclosing_type = TREE_TYPE (q);
+             BUILD_PTR_FROM_NAME (class_type, right);
+           }
        }
     }
 
@@ -5815,8 +5800,7 @@ do_resolve_class (enclosing, class_type, decl, cl)
   /* 2- And check for the type in the current compilation unit */
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
     {
-      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
-         !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
+      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
        load_class (TYPE_NAME (class_type), 0);
       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
     }
@@ -5867,7 +5851,7 @@ do_resolve_class (enclosing, class_type, decl, cl)
      by the caller. */
   if (cl)
     {
-      if (check_pkg_class_access (TYPE_NAME (class_type), cl, true))
+      if (check_pkg_class_access (TYPE_NAME (class_type), cl, true, NULL_TREE))
         return NULL_TREE;
     }
 
@@ -5901,8 +5885,7 @@ do_resolve_class (enclosing, class_type, decl, cl)
 }
 
 static tree
-qualify_and_find (class_type, package, name)
-     tree class_type, package, name;
+qualify_and_find (tree class_type, tree package, tree name)
 {
   tree new_qualified = merge_qualified_name (package, name);
   tree new_class_decl;
@@ -5911,9 +5894,8 @@ qualify_and_find (class_type, package, name)
     load_class (new_qualified, 0);
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
     {
-      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
-         !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
-       load_class (new_qualified, 0);
+      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
+       load_class (TREE_TYPE (new_class_decl), 0);
       TYPE_NAME (class_type) = new_qualified;
       return IDENTIFIER_CLASS_VALUE (new_qualified);
     }
@@ -5925,9 +5907,7 @@ qualify_and_find (class_type, package, name)
    called when type resolution is necessary during the walk pass.  */
 
 static tree
-resolve_and_layout (something, cl)
-     tree something;
-     tree cl;
+resolve_and_layout (tree something, tree cl)
 {
   tree decl, decl_type;
 
@@ -5988,8 +5968,7 @@ resolve_and_layout (something, cl)
    layout. The current parsing context is saved and restored */
 
 static tree
-resolve_no_layout (name, cl)
-     tree name, cl;
+resolve_no_layout (tree name, tree cl)
 {
   tree ptr, decl;
   BUILD_PTR_FROM_NAME (ptr, name);
@@ -6005,8 +5984,7 @@ resolve_no_layout (name, cl)
    use an identifier tree.  */
 
 static const char *
-purify_type_name (name)
-     const char *name;
+purify_type_name (const char *name)
 {
   int len = strlen (name);
   int bracket_found;
@@ -6024,8 +6002,7 @@ purify_type_name (name)
 /* The type CURRENT refers to can't be found. We print error messages.  */
 
 static void
-complete_class_report_errors (dep)
-     jdep *dep;
+complete_class_report_errors (jdep *dep)
 {
   const char *name;
 
@@ -6091,8 +6068,7 @@ complete_class_report_errors (dep)
    <init> */
 
 static const char *
-get_printable_method_name (decl)
-     tree decl;
+get_printable_method_name (tree decl)
 {
   const char *to_return;
   tree name = NULL_TREE;
@@ -6115,8 +6091,7 @@ get_printable_method_name (decl)
    function it's a FWL, so we can track errors more accurately.)  */
 
 static int
-check_method_redefinition (class, method)
-     tree class, method;
+check_method_redefinition (tree class, tree method)
 {
   tree redef, sig;
 
@@ -6146,9 +6121,8 @@ check_method_redefinition (class, method)
 
 /* Return 1 if check went ok, 0 otherwise.  */
 static int
-check_abstract_method_definitions (do_interface, class_decl, type)
-     int do_interface;
-     tree class_decl, type;
+check_abstract_method_definitions (int do_interface, tree class_decl,
+                                  tree type)
 {
   tree class = TREE_TYPE (class_decl);
   tree method, end_type;
@@ -6227,12 +6201,13 @@ check_abstract_method_definitions (do_interface, class_decl, type)
     {
       /* Check for implemented interfaces. */
       int i;
-      tree vector = TYPE_BINFO_BASETYPES (type);
-      for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
-       {
-         tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
-         ok = check_abstract_method_definitions (1, class_decl, super);
-       }
+      tree base_binfo;
+      
+      for (i = 1;
+          ok && BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo);
+          i++)
+       ok = check_abstract_method_definitions (1, class_decl,
+                                               BINFO_TYPE (base_binfo));
     }
 
   return ok;
@@ -6242,11 +6217,10 @@ check_abstract_method_definitions (do_interface, class_decl, type)
    methods.  */
 
 static void
-java_check_abstract_method_definitions (class_decl)
-     tree class_decl;
+java_check_abstract_method_definitions (tree class_decl)
 {
   tree class = TREE_TYPE (class_decl);
-  tree super, vector;
+  tree super, base_binfo;
   int i;
 
   if (CLASS_ABSTRACT (class_decl))
@@ -6260,12 +6234,8 @@ java_check_abstract_method_definitions (class_decl)
   } while (super != object_type_node);
 
   /* Check for implemented interfaces. */
-  vector = TYPE_BINFO_BASETYPES (class);
-  for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
-    {
-      super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
-      check_abstract_method_definitions (1, class_decl, super);
-    }
+  for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+    check_abstract_method_definitions (1, class_decl, BINFO_TYPE (base_binfo));
 }
 
 /* Check all the types method DECL uses and return 1 if all of them
@@ -6273,8 +6243,7 @@ java_check_abstract_method_definitions (class_decl)
    safe to build a method signature or not.  */
 
 static int
-check_method_types_complete (decl)
-     tree decl;
+check_method_types_complete (tree decl)
 {
   tree type = TREE_TYPE (decl);
   tree args;
@@ -6295,8 +6264,7 @@ check_method_types_complete (decl)
 /* Visible interface to check methods contained in CLASS_DECL */
 
 void
-java_check_methods (class_decl)
-     tree class_decl;
+java_check_methods (tree class_decl)
 {
   if (CLASS_METHOD_CHECKED_P (TREE_TYPE (class_decl)))
     return;
@@ -6309,14 +6277,37 @@ java_check_methods (class_decl)
   CLASS_METHOD_CHECKED_P (TREE_TYPE (class_decl)) = 1;
 }
 
+/* Like not_accessible_p, but doesn't refer to the current class at
+   all.  */
+static bool
+hack_is_accessible_p (tree member, tree from_where)
+{
+  int flags = get_access_flags_from_decl (member);
+
+  if (from_where == DECL_CONTEXT (member)
+      || (flags & ACC_PUBLIC))
+    return true;
+
+  if ((flags & ACC_PROTECTED))
+    {
+      if (inherits_from_p (from_where, DECL_CONTEXT (member)))
+       return true;
+    }
+
+  if ((flags & ACC_PRIVATE))
+    return false;
+
+  /* Package private, or protected.  */
+  return in_same_package (TYPE_NAME (from_where),
+                         TYPE_NAME (DECL_CONTEXT (member)));
+}
+
 /* Check all the methods of CLASS_DECL. Methods are first completed
    then checked according to regular method existence rules.  If no
    constructor for CLASS_DECL were encountered, then build its
    declaration.  */
-
 static void
-java_check_regular_methods (class_decl)
-     tree class_decl;
+java_check_regular_methods (tree class_decl)
 {
   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
   tree method;
@@ -6342,17 +6333,8 @@ java_check_regular_methods (class_decl)
       if (check_method_redefinition (class, method))
        continue;
 
-      /* If we see one constructor a mark so we don't generate the
-        default one. Also skip other verifications: constructors
-        can't be inherited hence hiden or overriden */
-     if (DECL_CONSTRUCTOR_P (method))
-       {
-        saw_constructor = 1;
-        continue;
-       }
-
-      /* We verify things thrown by the method. They must inherits from
-        java.lang.Throwable */
+      /* We verify things thrown by the method.  They must inherit from
+        java.lang.Throwable.  */
       for (mthrows = DECL_FUNCTION_THROWS (method);
           mthrows; mthrows = TREE_CHAIN (mthrows))
        {
@@ -6363,8 +6345,18 @@ java_check_regular_methods (class_decl)
                 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
        }
 
+      /* If we see one constructor a mark so we don't generate the
+        default one.  Also skip other verifications: constructors
+        can't be inherited hence hidden or overridden.  */
+      if (DECL_CONSTRUCTOR_P (method))
+       {
+         saw_constructor = 1;
+         continue;
+       }
+
       sig = build_java_argument_signature (TREE_TYPE (method));
-      found = lookup_argument_method2 (class, DECL_NAME (method), sig);
+      found = lookup_argument_method_generic (class, DECL_NAME (method), sig,
+                                             SEARCH_SUPER | SEARCH_INTERFACE);
 
       /* Inner class can't declare static methods */
       if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
@@ -6423,7 +6415,7 @@ java_check_regular_methods (class_decl)
            continue;
          parse_error_context
            (method_wfl,
-            "%s methods can't be overriden. Method `%s' is %s in class `%s'",
+            "%s methods can't be overridden. Method `%s' is %s in class `%s'",
             (METHOD_FINAL (found) ? "Final" : "Static"),
             lang_printable_name (found, 0),
             (METHOD_FINAL (found) ? "final" : "static"),
@@ -6437,7 +6429,7 @@ java_check_regular_methods (class_decl)
        {
          parse_error_context
            (method_wfl,
-            "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
+            "Instance methods can't be overridden by a static method. Method `%s' is an instance method in class `%s'",
             lang_printable_name (found, 0),
             IDENTIFIER_POINTER
               (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
@@ -6446,7 +6438,7 @@ java_check_regular_methods (class_decl)
 
       /* - Overriding/hiding public must be public
         - Overriding/hiding protected must be protected or public
-         - If the overriden or hidden method has default (package)
+         - If the overridden or hidden method has default (package)
            access, then the overriding or hiding method must not be
            private; otherwise, a compile-time error occurs.  If
            `found' belongs to an interface, things have been already
@@ -6468,13 +6460,20 @@ java_check_regular_methods (class_decl)
          continue;
        }
 
-      /* Overriding methods must have compatible `throws' clauses on checked
-        exceptions, if any */
-      check_throws_clauses (method, method_wfl, found);
-
-      /* Inheriting multiple methods with the same signature. FIXME */
+      /* Check this method against all the other implementations it
+        overrides.  Here we only check the class hierarchy; the rest
+        of the checking is done later.  If this method is just a
+        Miranda method, we can skip the check.  */
+      if (! METHOD_INVISIBLE (method))
+       check_concrete_throws_clauses (class, method, DECL_NAME (method), sig);
     }
 
+  /* The above throws clause check only looked at superclasses.  Now
+     we must also make sure that all methods declared in interfaces
+     have compatible throws clauses.  FIXME: there are more efficient
+     ways to organize this checking; we should implement one.  */
+  check_interface_throws_clauses (class, class);
+
   if (!TYPE_NVIRTUALS (class))
     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
 
@@ -6486,14 +6485,91 @@ java_check_regular_methods (class_decl)
     abort ();
 }
 
-/* Return a nonzero value if the `throws' clause of METHOD (if any)
-   is incompatible with the `throws' clause of FOUND (if any).  */
+/* Check to make sure that all the methods in all the interfaces
+   implemented by CLASS_DECL are compatible with the concrete
+   implementations available in CHECK_CLASS_DECL.  */
+static void
+check_interface_throws_clauses (tree check_class_decl, tree class_decl)
+{
+  for (; class_decl != NULL_TREE; class_decl = CLASSTYPE_SUPER (class_decl))
+    {
+      int i;
+
+      if (! CLASS_LOADED_P (class_decl))
+       {
+         if (CLASS_FROM_SOURCE_P (class_decl))
+           safe_layout_class (class_decl);
+         else
+           load_class (class_decl, 1);
+       }
+
+      for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (class_decl)) - 1; i > 0; --i)
+       {
+         tree interface
+           = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (class_decl), i));
+         tree iface_method;
+
+         for (iface_method = TYPE_METHODS (interface);
+              iface_method != NULL_TREE;
+              iface_method = TREE_CHAIN (iface_method))
+           {
+             tree sig, method;
+
+             /* First look for a concrete method implemented or
+                inherited by this class.  No need to search
+                interfaces here, since we're already looking through
+                all of them.  */
+             sig = build_java_argument_signature (TREE_TYPE (iface_method));
+             method
+               = lookup_argument_method_generic (check_class_decl,
+                                                 DECL_NAME (iface_method),
+                                                 sig, SEARCH_VISIBLE);
+             /* If we don't find an implementation, that is ok.  Any
+                potential errors from that are diagnosed elsewhere.
+                Also, multiple inheritance with conflicting throws
+                clauses is fine in the absence of a concrete
+                implementation.  */
+             if (method != NULL_TREE && !METHOD_ABSTRACT (method)
+                 && !METHOD_INVISIBLE (iface_method))
+               {
+                 tree method_wfl = DECL_FUNCTION_WFL (method);
+                 check_throws_clauses (method, method_wfl, iface_method);
+               }
+           }
 
+         /* Now check superinterfaces.  */
+         check_interface_throws_clauses (check_class_decl, interface);
+       }
+    }
+}
+
+/* Check throws clauses of a method against the clauses of all the
+   methods it overrides.  We do this by searching up the class
+   hierarchy, examining all matching accessible methods.  */
 static void
-check_throws_clauses (method, method_wfl, found)
-     tree method, method_wfl, found;
+check_concrete_throws_clauses (tree class, tree self_method,
+                              tree name, tree signature)
 {
-  tree mthrows, fthrows;
+  tree method = lookup_argument_method_generic (class, name, signature,
+                                               SEARCH_SUPER | SEARCH_VISIBLE);
+  while (method != NULL_TREE)
+    {
+      if (! METHOD_INVISIBLE (method) && hack_is_accessible_p (method, class))
+       check_throws_clauses (self_method, DECL_FUNCTION_WFL (self_method),
+                             method);
+
+      method = lookup_argument_method_generic (DECL_CONTEXT (method),
+                                              name, signature,
+                                              SEARCH_SUPER | SEARCH_VISIBLE);
+    }
+}
+
+/* Generate an error if the `throws' clause of METHOD (if any) is
+   incompatible with the `throws' clause of FOUND (if any).  */
+static void
+check_throws_clauses (tree method, tree method_wfl, tree found)
+{
+  tree mthrows;
 
   /* Can't check these things with class loaded from bytecode. FIXME */
   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
@@ -6502,35 +6578,38 @@ check_throws_clauses (method, method_wfl, found)
   for (mthrows = DECL_FUNCTION_THROWS (method);
        mthrows; mthrows = TREE_CHAIN (mthrows))
     {
+      tree fthrows;
+
       /* We don't verify unchecked expressions */
       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
        continue;
       /* Checked expression must be compatible */
       for (fthrows = DECL_FUNCTION_THROWS (found);
           fthrows; fthrows = TREE_CHAIN (fthrows))
-       if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
-         break;
+       {
+         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
+           break;
+       }
       if (!fthrows)
        {
          parse_error_context
-           (method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
+           (method_wfl, "Invalid checked exception class `%s' in `throws' clause.  The exception must be a subclass of an exception thrown by `%s' from class `%s'",
             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
             lang_printable_name (found, 0),
             IDENTIFIER_POINTER
-              (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
+            (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
        }
     }
 }
 
 /* Check abstract method of interface INTERFACE */
-
 static void
-java_check_abstract_methods (interface_decl)
-     tree interface_decl;
+java_check_abstract_methods (tree interface_decl)
 {
-  int i, n;
-  tree method, basetype_vec, found;
+  int i;
+  tree method, found;
   tree interface = TREE_TYPE (interface_decl);
+  tree base_binfo;
 
   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
     {
@@ -6538,8 +6617,7 @@ java_check_abstract_methods (interface_decl)
       if (check_method_redefinition (interface, method))
        continue;
 
-      /* 3- Overriding is OK as far as we preserve the return type and
-        the thrown exceptions (FIXME) */
+      /* 3- Overriding is OK as far as we preserve the return type.  */
       found = lookup_java_interface_method2 (interface, method);
       if (found)
        {
@@ -6557,16 +6635,11 @@ java_check_abstract_methods (interface_decl)
     }
 
   /* 4- Inherited methods can't differ by their returned types */
-  if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
-    return;
-  n = TREE_VEC_LENGTH (basetype_vec);
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (interface), i, base_binfo); i++)
     {
       tree sub_interface_method, sub_interface;
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
-      if (!vec_elt)
-       continue;
-      sub_interface = BINFO_TYPE (vec_elt);
+
+      sub_interface = BINFO_TYPE (base_binfo);
       for (sub_interface_method = TYPE_METHODS (sub_interface);
           sub_interface_method;
           sub_interface_method = TREE_CHAIN (sub_interface_method))
@@ -6594,28 +6667,23 @@ java_check_abstract_methods (interface_decl)
    signature. Return a matching method only if their types differ.  */
 
 static tree
-lookup_java_interface_method2 (class, method_decl)
-     tree class, method_decl;
+lookup_java_interface_method2 (tree class, tree method_decl)
 {
-  int i, n;
-  tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
-
-  if (!basetype_vec)
-    return NULL_TREE;
+  int i;
+  tree base_binfo;
+  tree to_return;
 
-  n = TREE_VEC_LENGTH (basetype_vec);
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
     {
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
-      if ((BINFO_TYPE (vec_elt) != object_type_node)
+      if ((BINFO_TYPE (base_binfo) != object_type_node)
          && (to_return =
-             lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
+             lookup_java_method2 (BINFO_TYPE (base_binfo), method_decl, 1)))
        return to_return;
     }
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
     {
       to_return = lookup_java_interface_method2
-       (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
+       (BINFO_TYPE (base_binfo), method_decl);
       if (to_return)
        return to_return;
     }
@@ -6627,9 +6695,7 @@ lookup_java_interface_method2 (class, method_decl)
    matching method only if their types differ.  */
 
 static tree
-lookup_java_method2 (clas, method_decl, do_interface)
-     tree clas, method_decl;
-     int do_interface;
+lookup_java_method2 (tree clas, tree method_decl, int do_interface)
 {
   tree method, method_signature, method_name, method_type, name;
 
@@ -6662,8 +6728,7 @@ lookup_java_method2 (clas, method_decl, do_interface)
 
 static GTY(()) tree cl_v;
 static tree
-lookup_cl (decl)
-     tree decl;
+lookup_cl (tree decl)
 {
   char *line, *found;
 
@@ -6676,7 +6741,7 @@ lookup_cl (decl)
     }
 
   EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
-  EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE_FIRST (decl), -1);
+  EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1);
 
   line = java_get_line_col (EXPR_WFL_FILENAME (cl_v),
                            EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v));
@@ -6692,8 +6757,7 @@ lookup_cl (decl)
 /* Look for a simple name in the single-type import list */
 
 static tree
-find_name_in_single_imports (name)
-     tree name;
+find_name_in_single_imports (tree name)
 {
   tree node;
 
@@ -6707,7 +6771,7 @@ find_name_in_single_imports (name)
 /* Process all single-type import. */
 
 static int
-process_imports ()
+process_imports (void)
 {
   tree import;
   int error_found;
@@ -6732,17 +6796,21 @@ process_imports ()
          QUALIFIED_P (to_be_found) = 1;
          load_class (to_be_found, 0);
          error_found =
-           check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true);
+           check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true, NULL_TREE);
 
          /* We found it, we can bail out */
          if (IDENTIFIER_CLASS_VALUE (to_be_found))
-           break;
+           {
+             check_deprecation (TREE_PURPOSE (import),
+                                IDENTIFIER_CLASS_VALUE (to_be_found));
+             break;
+           }
 
          /* We haven't found it. Maybe we're trying to access an
             inner class.  The only way for us to know is to try again
             after having dropped a qualifier. If we can't break it further,
             we have an error. */
-         if (breakdown_qualified (&left, NULL, to_be_found))
+         if (split_qualified_name (&left, NULL, to_be_found))
            break;
 
          to_be_found = left;
@@ -6766,9 +6834,7 @@ process_imports ()
    statement.  */
 
 static void
-find_in_imports (enclosing_type, class_type)
-     tree enclosing_type;
-     tree class_type;
+find_in_imports (tree enclosing_type, tree class_type)
 {
   tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) :
                 ctxp->import_list);
@@ -6785,9 +6851,7 @@ find_in_imports (enclosing_type, class_type)
 }
 
 static int
-note_possible_classname (name, len)
-     const char *name;
-     int len;
+note_possible_classname (const char *name, int len)
 {
   tree node;
   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
@@ -6807,8 +6871,7 @@ note_possible_classname (name, len)
    directory.  */
 
 static void
-read_import_dir (wfl)
-     tree wfl;
+read_import_dir (tree wfl)
 {
   tree package_id = EXPR_WFL_NODE (wfl);
   const char *package_name = IDENTIFIER_POINTER (package_id);
@@ -6838,7 +6901,7 @@ read_import_dir (wfl)
          buffer_grow (filename, entry_length);
          memcpy (filename->data, entry_name, entry_length - 1);
          filename->data[entry_length-1] = '\0';
-         zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
+         zipf = opendir_in_zip ((const char *) filename->data, jcf_path_is_system (entry));
          if (zipf == NULL)
            error ("malformed .zip archive in CLASSPATH: %s", entry_name);
          else
@@ -6858,7 +6921,7 @@ read_import_dir (wfl)
                  int current_entry_len = zipd->filename_length;
 
                  if (current_entry_len >= BUFFER_LENGTH (filename)
-                     && strncmp (filename->data, current_entry,
+                     && strncmp ((const char *) filename->data, current_entry,
                                  BUFFER_LENGTH (filename)) != 0)
                    continue;
                  found |= note_possible_classname (current_entry,
@@ -6870,7 +6933,7 @@ read_import_dir (wfl)
        {
          BUFFER_RESET (filename);
          buffer_grow (filename, entry_length + package_length + 4);
-         strcpy (filename->data, entry_name);
+         strcpy ((char *) filename->data, entry_name);
          filename->ptr = filename->data + entry_length;
          for (k = 0; k < package_length; k++)
            {
@@ -6879,7 +6942,7 @@ read_import_dir (wfl)
            }
          *filename->ptr = '\0';
 
-         dirp = opendir (filename->data);
+         dirp = opendir ((const char *) filename->data);
          if (dirp == NULL)
            continue;
          *filename->ptr++ = '/';
@@ -6893,8 +6956,8 @@ read_import_dir (wfl)
              d_name = direntp->d_name;
              len = strlen (direntp->d_name);
              buffer_grow (filename, len+1);
-             strcpy (filename->ptr, d_name);
-             found |= note_possible_classname (filename->data + entry_length,
+             strcpy ((char *) filename->ptr, d_name);
+             found |= note_possible_classname ((const char *) filename->data + entry_length,
                                                package_length+len+1);
            }
          if (dirp)
@@ -6929,9 +6992,7 @@ read_import_dir (wfl)
    entire list, to detected potential double definitions.  */
 
 static int
-find_in_imports_on_demand (enclosing_type, class_type)
-     tree enclosing_type;
-     tree class_type;
+find_in_imports_on_demand (tree enclosing_type, tree class_type)
 {
   tree class_type_name = TYPE_NAME (class_type);
   tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) :
@@ -6943,7 +7004,7 @@ find_in_imports_on_demand (enclosing_type, class_type)
 
   for (; import; import = TREE_CHAIN (import))
     {
-      int saved_lineno = lineno;
+      int saved_lineno = input_line;
       int access_check;
       const char *id_name;
       tree decl, type_name_copy;
@@ -6960,9 +7021,9 @@ find_in_imports_on_demand (enclosing_type, class_type)
       if (! (node = maybe_get_identifier (id_name)))
        continue;
 
-      /* Setup lineno so that it refers to the line of the import (in
+      /* Setup input_line so that it refers to the line of the import (in
         case we parse a class file and encounter errors */
-      lineno = EXPR_WFL_LINENO (TREE_PURPOSE (import));
+      input_line = EXPR_WFL_LINENO (TREE_PURPOSE (import));
 
       type_name_copy = TYPE_NAME (class_type);
       TYPE_NAME (class_type) = node;
@@ -6971,20 +7032,19 @@ find_in_imports_on_demand (enclosing_type, class_type)
       access_check = -1;
       /* If there is no DECL set for the class or if the class isn't
         loaded and not seen in source yet, then load */
-      if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
-                   && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
+      if (!decl || ! CLASS_LOADED_P (TREE_TYPE (decl)))
        {
          load_class (node, 0);
          decl = IDENTIFIER_CLASS_VALUE (node);
        }
       if (decl && ! INNER_CLASS_P (TREE_TYPE (decl)))
        access_check = check_pkg_class_access (node, TREE_PURPOSE (import),
-                                              false);
+                                              false, NULL_TREE);
       else
        /* 6.6.1: Inner classes are subject to member access rules. */
        access_check = 0;
 
-      lineno = saved_lineno;
+      input_line = saved_lineno;
 
       /* If the loaded class is not accessible or couldn't be loaded,
         we restore the original TYPE_NAME and process the next
@@ -7031,8 +7091,7 @@ find_in_imports_on_demand (enclosing_type, class_type)
    particular package is added only once.  */
 
 static void
-register_package (name)
-     tree name;
+register_package (tree name)
 {
   static htab_t pht;
   void **e;
@@ -7049,8 +7108,7 @@ register_package (name)
 }
 
 static tree
-resolve_package (pkg, next, type_name)
-     tree pkg, *next, *type_name;
+resolve_package (tree pkg, tree *next, tree *type_name)
 {
   tree current;
   tree decl = NULL_TREE;
@@ -7091,8 +7149,7 @@ resolve_package (pkg, next, type_name)
    access is being attempted. */
 
 static void
-check_inner_class_access (decl, enclosing_decl, cl)
-     tree decl, enclosing_decl, cl;
+check_inner_class_access (tree decl, tree enclosing_decl, tree cl)
 {
   const char *access;
   tree enclosing_decl_type;
@@ -7168,10 +7225,11 @@ check_inner_class_access (decl, enclosing_decl, cl)
 /* Accessibility check for top-level classes. If CLASS_NAME is in a
    foreign package, it must be PUBLIC. Return 0 if no access
    violations were found, 1 otherwise. If VERBOSE is true and an error
-   was found, it is reported and accounted for.  */
+   was found, it is reported and accounted for.  If CL is NULL then 
+   look it up with THIS_DECL.  */
 
 static int
-check_pkg_class_access (tree class_name, tree cl, bool verbose)
+check_pkg_class_access (tree class_name, tree cl, bool verbose, tree this_decl)
 {
   tree type;
 
@@ -7186,7 +7244,7 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
       /* Access to a private class within the same package is
          allowed. */
       tree l, r;
-      breakdown_qualified (&l, &r, class_name);
+      split_qualified_name (&l, &r, class_name);
       if (!QUALIFIED_P (class_name) && !ctxp->package)
        /* Both in the empty package. */
         return 0;
@@ -7196,7 +7254,8 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
 
       if (verbose)
        parse_error_context
-         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
+         (cl == NULL ? lookup_cl (this_decl): cl,
+           "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
           (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
           IDENTIFIER_POINTER (class_name));
       return 1;
@@ -7207,10 +7266,7 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
 /* Local variable declaration. */
 
 static void
-declare_local_variables (modifier, type, vlist)
-     int modifier;
-     tree type;
-     tree vlist;
+declare_local_variables (int modifier, tree type, tree vlist)
 {
   tree decl, current, saved_type;
   tree type_wfl = NULL_TREE;
@@ -7292,6 +7348,13 @@ declare_local_variables (modifier, type, vlist)
       if (init && java_error_count)
        init = NULL_TREE;
 
+      /* Remember it if this is an initialized-upon-declaration final
+         variable.  */
+      if (init && final_p)
+        {
+          DECL_LOCAL_FINAL_IUD (decl) = 1;
+        }
+
       /* Add the initialization function to the current function's code */
       if (init)
        {
@@ -7318,8 +7381,7 @@ declare_local_variables (modifier, type, vlist)
 /* Called during parsing. Build decls from argument list.  */
 
 static void
-source_start_java_method (fndecl)
-     tree fndecl;
+source_start_java_method (tree fndecl)
 {
   tree tem;
   tree parm_decl;
@@ -7374,15 +7436,13 @@ source_start_java_method (fndecl)
 /* Called during parsing. Creates an artificial method declaration.  */
 
 static tree
-create_artificial_method (class, flags, type, name, args)
-     tree class;
-     int flags;
-     tree type, name, args;
+create_artificial_method (tree class, int flags, tree type,
+                         tree name, tree args)
 {
   tree mdecl;
 
   java_parser_context_save_global ();
-  lineno = 0;
+  input_line = 0;
   mdecl = make_node (FUNCTION_TYPE);
   TREE_TYPE (mdecl) = type;
   TYPE_ARG_TYPES (mdecl) = args;
@@ -7395,18 +7455,16 @@ create_artificial_method (class, flags, type, name, args)
 /* Starts the body if an artificial method.  */
 
 static void
-start_artificial_method_body (mdecl)
-     tree mdecl;
+start_artificial_method_body (tree mdecl)
 {
   DECL_SOURCE_LINE (mdecl) = 1;
-  DECL_SOURCE_LINE_MERGE (mdecl, 1);
+  DECL_FUNCTION_LAST_LINE (mdecl) = 1;
   source_start_java_method (mdecl);
   enter_block ();
 }
 
 static void
-end_artificial_method_body (mdecl)
-     tree mdecl;
+end_artificial_method_body (tree mdecl)
 {
   /* exit_block modifies DECL_FUNCTION_BODY (current_function_decl).
      It has to be evaluated first. (if mdecl is current_function_decl,
@@ -7419,9 +7477,7 @@ end_artificial_method_body (mdecl)
 /* Dump a tree of some kind.  This is a convenience wrapper for the
    dump_* functions in tree-dump.c.  */
 static void
-dump_java_tree (phase, t)
-     enum tree_dump_index phase;
-     tree t;
+dump_java_tree (enum tree_dump_index phase, tree t)
 {
   FILE *stream;
   int flags;
@@ -7438,7 +7494,7 @@ dump_java_tree (phase, t)
 /* Terminate a function and expand its body.  */
 
 static void
-source_end_java_method ()
+source_end_java_method (void)
 {
   tree fndecl = current_function_decl;
 
@@ -7446,53 +7502,29 @@ source_end_java_method ()
     return;
 
   java_parser_context_save_global ();
-  lineno = ctxp->last_ccb_indent1;
+  input_line = ctxp->last_ccb_indent1;
 
   /* Turn function bodies with only a NOP expr null, so they don't get
      generated at all and we won't get warnings when using the -W
      -Wall flags. */
-  if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
+  if (IS_EMPTY_STMT (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))))
     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
 
-  /* We've generated all the trees for this function, and it has been
-     patched.  Dump it to a file if the user requested it.  */
-  dump_java_tree (TDI_original, fndecl);
-
-  java_optimize_inline (fndecl);
-
-  /* Generate function's code */
   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
       && ! flag_emit_class_files
       && ! flag_emit_xref)
-    expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
-
-  /* pop out of its parameters */
-  pushdecl_force_head (DECL_ARGUMENTS (fndecl));
-  poplevel (1, 0, 1);
-  BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
-
-  /* Generate rtl for function exit.  */
-  if (! flag_emit_class_files && ! flag_emit_xref)
-    {
-      lineno = DECL_SOURCE_LINE_LAST (fndecl);
-      expand_function_end (input_filename, lineno, 0);
-
-      DECL_SOURCE_LINE (fndecl) = DECL_SOURCE_LINE_FIRST (fndecl);
-
-      /* Run the optimizers and output assembler code for this function. */
-      rest_of_compilation (fndecl);
-    }
+    finish_method (fndecl);
 
   current_function_decl = NULL_TREE;
   java_parser_context_restore_global ();
+  current_function_decl = NULL_TREE;
 }
 
 /* Record EXPR in the current function block. Complements compound
    expression second operand if necessary.  */
 
 tree
-java_method_add_stmt (fndecl, expr)
-     tree fndecl, expr;
+java_method_add_stmt (tree fndecl, tree expr)
 {
   if (!GET_CURRENT_BLOCK (fndecl))
     return NULL_TREE;
@@ -7500,8 +7532,7 @@ java_method_add_stmt (fndecl, expr)
 }
 
 static tree
-add_stmt_to_block (b, type, stmt)
-     tree b, type, stmt;
+add_stmt_to_block (tree b, tree type, tree stmt)
 {
   tree body = BLOCK_EXPR_BODY (b), c;
 
@@ -7516,24 +7547,10 @@ add_stmt_to_block (b, type, stmt)
   return c;
 }
 
-/* Add STMT to EXISTING if possible, otherwise create a new
-   COMPOUND_EXPR and add STMT to it. */
-
-static tree
-add_stmt_to_compound (existing, type, stmt)
-     tree existing, type, stmt;
-{
-  /* Keep track of this for inlining.  */
-  if (current_function_decl)
-    ++DECL_NUM_STMTS (current_function_decl);
-
-  if (existing)
-    return build (COMPOUND_EXPR, type, existing, stmt);
-  else
-    return stmt;
-}
+/* Lays out the methods for the classes seen so far.  */
 
-void java_layout_seen_class_methods ()
+void
+java_layout_seen_class_methods (void)
 {
   tree previous_list = all_class_list;
   tree end = NULL_TREE;
@@ -7543,7 +7560,17 @@ void java_layout_seen_class_methods ()
     {
       for (current = previous_list;
           current != end; current = TREE_CHAIN (current))
-       layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
+        {
+          tree cls = TREE_TYPE (TREE_VALUE (current));
+
+          if (! CLASS_LOADED_P (cls))
+            load_class (cls, 0);
+
+          layout_class_methods (cls);
+        }
+
+      /* Note that new classes might have been added while laying out
+         methods, changing the value of all_class_list.  */
 
       if (previous_list != all_class_list)
        {
@@ -7557,13 +7584,13 @@ void java_layout_seen_class_methods ()
 
 static GTY(()) tree stop_reordering;
 void
-java_reorder_fields ()
+java_reorder_fields (void)
 {
   tree current;
 
   for (current = gclass_list; current; current = TREE_CHAIN (current))
     {
-      current_class = TREE_TYPE (TREE_VALUE (current));
+      output_class = current_class = TREE_TYPE (TREE_VALUE (current));
 
       if (current_class == stop_reordering)
        break;
@@ -7602,7 +7629,7 @@ java_reorder_fields ()
    classes */
 
 void
-java_layout_classes ()
+java_layout_classes (void)
 {
   tree current;
   int save_error_count = java_error_count;
@@ -7620,7 +7647,7 @@ java_layout_classes ()
 
   for (current = gclass_list; current; current = TREE_CHAIN (current))
     {
-      current_class = TREE_TYPE (TREE_VALUE (current));
+      output_class = current_class = TREE_TYPE (TREE_VALUE (current));
       layout_class (current_class);
 
       /* Error reported by the caller */
@@ -7635,11 +7662,11 @@ java_layout_classes ()
   java_parse_abort_on_error ();
 }
 
-/* Expand methods in the current set of classes rememebered for
+/* Expand methods in the current set of classes remembered for
    generation.  */
 
 static void
-java_complete_expand_classes ()
+java_complete_expand_classes (void)
 {
   tree current;
 
@@ -7654,13 +7681,10 @@ java_complete_expand_classes ()
    classes, if any.  */
 
 static void
-java_complete_expand_class (outer)
-     tree outer;
+java_complete_expand_class (tree outer)
 {
   tree inner_list;
 
-  set_nested_class_simple_name_value (outer, 1); /* Set */
-
   /* We need to go after all inner classes and start expanding them,
      starting with most nested ones. We have to do that because nested
      classes might add functions to outer classes */
@@ -7670,7 +7694,6 @@ java_complete_expand_class (outer)
     java_complete_expand_class (TREE_PURPOSE (inner_list));
 
   java_complete_expand_methods (outer);
-  set_nested_class_simple_name_value (outer, 0); /* Reset */
 }
 
 /* Expand methods registered in CLASS_DECL. The general idea is that
@@ -7681,15 +7704,11 @@ java_complete_expand_class (outer)
    constructors and then <clinit>.  */
 
 static void
-java_complete_expand_methods (class_decl)
-     tree class_decl;
+java_complete_expand_methods (tree class_decl)
 {
   tree clinit, decl, first_decl;
 
-  current_class = TREE_TYPE (class_decl);
-
-  /* Initialize a new constant pool */
-  init_outgoing_cpool ();
+  output_class = current_class = TREE_TYPE (class_decl);
 
   /* Pre-expand <clinit> to figure whether we really need it or
      not. If we do need it, we pre-expand the static fields so they're
@@ -7711,21 +7730,9 @@ java_complete_expand_methods (class_decl)
   /* Now do the constructors */
   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
     {
-      int no_body;
-
       if (!DECL_CONSTRUCTOR_P (decl))
        continue;
-
-      no_body = !DECL_FUNCTION_BODY (decl);
-      /* Don't generate debug info on line zero when expanding a
-        generated constructor. */
-      if (no_body)
-       restore_line_number_status (1);
-
       java_complete_expand_method (decl);
-
-      if (no_body)
-       restore_line_number_status (0);
     }
 
   /* First, do the ordinary methods. */
@@ -7774,17 +7781,13 @@ java_complete_expand_methods (class_decl)
       if (DECL_CONSTRUCTOR_P (decl)
          && verify_constructor_circularity (decl, decl))
        break;
-
-  /* Save the constant pool. We'll need to restore it later. */
-  TYPE_CPOOL (current_class) = outgoing_cpool;
 }
 
 /* Attempt to create <clinit>. Pre-expand static fields so they can be
    safely used in some other methods/constructors.  */
 
 static tree
-maybe_generate_pre_expand_clinit (class_type)
-     tree class_type;
+maybe_generate_pre_expand_clinit (tree class_type)
 {
   tree current, mdecl;
 
@@ -7814,7 +7817,7 @@ maybe_generate_pre_expand_clinit (class_type)
       /* We build the assignment expression that will initialize the
         field to its value. There are strict rules on static
         initializers (8.5). FIXME */
-      if (TREE_CODE (stmt) != BLOCK && stmt != empty_stmt_node)
+      if (TREE_CODE (stmt) != BLOCK && !IS_EMPTY_STMT (stmt))
        stmt = build_debugable_stmt (EXPR_WFL_LINECOL (stmt), stmt);
       java_method_add_stmt (mdecl, stmt);
     }
@@ -7843,8 +7846,7 @@ maybe_generate_pre_expand_clinit (class_type)
    MODIFY_EXPR with a constant value.  */
 
 static int
-analyze_clinit_body (this_class, bbody)
-     tree this_class, bbody;
+analyze_clinit_body (tree this_class, tree bbody)
 {
   while (bbody)
     switch (TREE_CODE (bbody))
@@ -7892,8 +7894,7 @@ analyze_clinit_body (this_class, bbody)
    is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
 
 static int
-maybe_yank_clinit (mdecl)
-     tree mdecl;
+maybe_yank_clinit (tree mdecl)
 {
   tree type, current;
   tree fbody, bbody;
@@ -7910,7 +7911,7 @@ maybe_yank_clinit (mdecl)
     bbody = BLOCK_EXPR_BODY (bbody);
   else
     return 0;
-  if (bbody && ! flag_emit_class_files && bbody != empty_stmt_node)
+  if (bbody && ! flag_emit_class_files && !IS_EMPTY_STMT (bbody))
     return 0;
 
   type = DECL_CONTEXT (mdecl);
@@ -7944,7 +7945,7 @@ maybe_yank_clinit (mdecl)
 
   /* Now we analyze the method body and look for something that
      isn't a MODIFY_EXPR */
-  if (bbody != empty_stmt_node && analyze_clinit_body (type, bbody))
+  if (!IS_EMPTY_STMT (bbody) && analyze_clinit_body (type, bbody))
     return 0;
 
   /* Get rid of <clinit> in the class' list of methods */
@@ -7965,9 +7966,8 @@ maybe_yank_clinit (mdecl)
 /* Install the argument from MDECL. Suitable to completion and
    expansion of mdecl's body.  */
 
-static void
-start_complete_expand_method (mdecl)
-     tree mdecl;
+void
+start_complete_expand_method (tree mdecl)
 {
   tree tem;
 
@@ -7980,7 +7980,7 @@ start_complete_expand_method (mdecl)
       /* TREE_CHAIN (tem) will change after pushdecl. */
       tree next = TREE_CHAIN (tem);
       tree type = TREE_TYPE (tem);
-      if (PROMOTE_PROTOTYPES
+      if (targetm.calls.promote_prototypes (type)
          && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
          && INTEGRAL_TYPE_P (type))
        type = integer_type_node;
@@ -7992,7 +7992,7 @@ start_complete_expand_method (mdecl)
       TREE_CHAIN (tem) = next;
     }
   pushdecl_force_head (DECL_ARGUMENTS (mdecl));
-  lineno = DECL_SOURCE_LINE_FIRST (mdecl);
+  input_line = DECL_SOURCE_LINE (mdecl);
   build_result_decl (mdecl);
 }
 
@@ -8000,8 +8000,7 @@ start_complete_expand_method (mdecl)
 /* Complete and expand a method.  */
 
 static void
-java_complete_expand_method (mdecl)
-     tree mdecl;
+java_complete_expand_method (tree mdecl)
 {
   tree fbody, block_body, exception_copy;
 
@@ -8105,21 +8104,22 @@ java_complete_expand_method (mdecl)
 /* For with each class for which there's code to generate. */
 
 static void
-java_expand_method_bodies (class)
-     tree class;
+java_expand_method_bodies (tree class)
 {
   tree decl;
   for (decl = TYPE_METHODS (class); decl; decl = TREE_CHAIN (decl))
     {
-      if (!DECL_FUNCTION_BODY (decl))
+      tree block;
+
+      if (! DECL_FUNCTION_BODY (decl))
        continue;
 
       current_function_decl = decl;
 
-      /* Save the function for inlining.  */
-      if (flag_inline_trees)
-       DECL_SAVED_TREE (decl) =
-         BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
+      block = BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
+
+      /* Save the function body for gimplify and inlining.  */
+      DECL_SAVED_TREE (decl) = block;
 
       /* It's time to assign the variable flagging static class
         initialization based on which classes invoked static methods
@@ -8152,15 +8152,7 @@ java_expand_method_bodies (class)
            }
        }
 
-      /* Prepare the function for RTL expansion */
-      start_complete_expand_method (decl);
-
-      /* Expand function start, generate initialization flag
-        assignment, and handle synchronized methods. */
-      complete_start_java_method (decl);
-
-      /* Expand the rest of the function body and terminate
-         expansion. */
+      /* Expand the function body.  */
       source_end_java_method ();
     }
 }
@@ -8178,8 +8170,7 @@ java_expand_method_bodies (class)
    be later turned into a write by calling outer_field_access_fix.  */
 
 static tree
-build_outer_field_access (id, decl)
-     tree id, decl;
+build_outer_field_access (tree id, tree decl)
 {
   tree access = NULL_TREE;
   tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
@@ -8228,8 +8219,7 @@ build_outer_field_access (id, decl)
    access.  */
 
 static int
-outer_field_access_p (type, decl)
-    tree type, decl;
+outer_field_access_p (tree type, tree decl)
 {
   if (!INNER_CLASS_TYPE_P (type)
       || TREE_CODE (decl) != FIELD_DECL
@@ -8237,7 +8227,7 @@ outer_field_access_p (type, decl)
     return 0;
 
   /* If the inner class extends the declaration context of the field
-     we're try to acces, then this isn't an outer field access */
+     we're trying to access, then this isn't an outer field access */
   if (inherits_from_p (type, DECL_CONTEXT (decl)))
     return 0;
 
@@ -8267,8 +8257,8 @@ outer_field_access_p (type, decl)
    call if necessary. */
 
 static int
-outer_field_expanded_access_p (node, name, arg_type, arg)
-    tree node, *name, *arg_type, *arg;
+outer_field_expanded_access_p (tree node, tree *name, tree *arg_type,
+                              tree *arg)
 {
   int identified = 0;
 
@@ -8314,8 +8304,7 @@ outer_field_expanded_access_p (node, name, arg_type, arg)
    be identified. */
 
 static tree
-outer_field_access_fix (wfl, node, rhs)
-    tree wfl, node, rhs;
+outer_field_access_fix (tree wfl, tree node, tree rhs)
 {
   tree name, arg_type, arg;
 
@@ -8335,9 +8324,8 @@ outer_field_access_fix (wfl, node, rhs)
    read access.  */
 
 static tree
-build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
-    int lc;
-    tree type, access_method_name, arg1, arg2;
+build_outer_field_access_expr (int lc, tree type, tree access_method_name,
+                              tree arg1, tree arg2)
 {
   tree args, cn, access;
 
@@ -8354,7 +8342,7 @@ build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
 }
 
 static tree
-build_new_access_id ()
+build_new_access_id (void)
 {
   static int access_n_counter = 1;
   char buffer [128];
@@ -8378,8 +8366,7 @@ build_new_access_id ()
 */
 
 static tree
-build_outer_field_access_methods (decl)
-    tree decl;
+build_outer_field_access_methods (tree decl)
 {
   tree id, args, stmt, mdecl;
 
@@ -8429,8 +8416,8 @@ build_outer_field_access_methods (decl)
 /* Build an field access method NAME.  */
 
 static tree
-build_outer_field_access_method (class, type, name, args, body)
-    tree class, type, name, args, body;
+build_outer_field_access_method (tree class, tree type, tree name,
+                                tree args, tree body)
 {
   tree saved_current_function_decl, mdecl;
 
@@ -8454,8 +8441,7 @@ build_outer_field_access_method (class, type, name, args, body)
    certain kinds of method invocation from inner classes.  */
 
 static tree
-build_outer_method_access_method (decl)
-    tree decl;
+build_outer_method_access_method (tree decl)
 {
   tree saved_current_function_decl, mdecl;
   tree args = NULL_TREE, call_args = NULL_TREE;
@@ -8495,7 +8481,7 @@ build_outer_method_access_method (decl)
   /* There is a potential bug here. We should be able to use
      fix_method_argument_names, but then arg names get mixed up and
      eventually a constructor will have its this$0 altered and the
-     outer context won't be assignment properly. The test case is
+     outer context won't be assignment properly. The testcase is
      stub.java FIXME */
   TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
 
@@ -8544,9 +8530,7 @@ build_outer_method_access_method (decl)
    for example build_outer_field_access).  */
 
 static tree
-build_access_to_thisn (from, to, lc)
-     tree from, to;
-     int lc;
+build_access_to_thisn (tree from, tree to, int lc)
 {
   tree access = NULL_TREE;
 
@@ -8588,8 +8572,7 @@ build_access_to_thisn (from, to, lc)
    attribute so that they can't be referred to directly.  */
 
 static tree
-maybe_build_thisn_access_method (type)
-    tree type;
+maybe_build_thisn_access_method (tree type)
 {
   tree mdecl, args, stmt, rtype;
   tree saved_current_function_decl;
@@ -8634,8 +8617,7 @@ static GTY(()) tree saved_thisn;
 static GTY(()) tree saved_type;
 
 static tree
-build_current_thisn (type)
-    tree type;
+build_current_thisn (tree type)
 {
   static int saved_i = -1;
   static int saved_type_i = 0;
@@ -8669,12 +8651,12 @@ build_current_thisn (type)
   return saved_thisn;
 }
 
-/* Return the assignement to the hidden enclosing context `this$<n>'
+/* Return the assignment to the hidden enclosing context `this$<n>'
    by the second incoming parameter to the innerclass constructor. The
    form used is `this.this$<n> = this$<n>;'.  */
 
 static tree
-build_thisn_assign ()
+build_thisn_assign (void)
 {
   if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
     {
@@ -8682,7 +8664,7 @@ build_thisn_assign ()
       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
                                         build_wfl_node (thisn), 0);
       tree rhs = build_wfl_node (thisn);
-      EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
+      EXPR_WFL_SET_LINECOL (lhs, input_line, 0);
       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
     }
   return NULL_TREE;
@@ -8703,12 +8685,11 @@ static GTY(()) tree get_message_wfl;
 static GTY(()) tree type_parm_wfl;
 
 static tree
-build_dot_class_method (class)
-     tree class;
+build_dot_class_method (tree class)
 {
 #define BWF(S) build_wfl_node (get_identifier ((S)))
 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
-  tree args, tmp, saved_current_function_decl, mdecl;
+  tree args, tmp, saved_current_function_decl, mdecl, qual_name;
   tree stmt, throw_stmt;
 
   if (!get_message_wfl)
@@ -8725,15 +8706,17 @@ build_dot_class_method (class)
   /* Build the qualified name java.lang.Class.forName */
   tmp = MQN (MQN (MQN (BWF ("java"),
                       BWF ("lang")), BWF ("Class")), BWF ("forName"));
-  load_class (class_not_found_type_node, 1);
-  load_class (no_class_def_found_type_node, 1);
 
   /* Create the "class$" function */
   mdecl = create_artificial_method (class, ACC_STATIC,
                                    build_pointer_type (class_type_node),
                                    classdollar_identifier_node, args);
-  DECL_FUNCTION_THROWS (mdecl) =
-    build_tree_list (NULL_TREE, no_class_def_found_type_node);
+  qual_name = MQN (MQN (BWF ("java"), BWF ("lang")),
+                  BWF ("NoClassDefFoundError"));
+  DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE, qual_name);
+  register_incomplete_type (JDEP_EXCEPTION, qual_name, NULL_TREE, NULL_TREE);
+  JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
+    &TREE_VALUE (DECL_FUNCTION_THROWS (mdecl));
 
   /* We start by building the try block. We need to build:
        return (java.lang.Class.forName (type)); */
@@ -8756,8 +8739,9 @@ build_dot_class_method (class)
   throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
 
   /* Encapsulate STMT in a try block. The catch clause executes THROW_STMT */
-  stmt = encapsulate_with_try_catch (0, class_not_found_type_node,
-                                    stmt, throw_stmt);
+  qual_name = MQN (MQN (BWF ("java"), BWF ("lang")),
+                  BWF ("ClassNotFoundException"));
+  stmt = encapsulate_with_try_catch (0, qual_name, stmt, throw_stmt);
 
   fix_method_argument_names (args, mdecl);
   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
@@ -8772,10 +8756,10 @@ build_dot_class_method (class)
 }
 
 static tree
-build_dot_class_method_invocation (type)
-     tree type;
+build_dot_class_method_invocation (tree this_class, tree type)
 {
-  tree sig_id, s;
+  tree dot_class_method = TYPE_DOT_CLASS (this_class);
+  tree sig_id, s, t;
 
   if (TYPE_ARRAY_P (type))
     sig_id = build_java_signature (type);
@@ -8788,8 +8772,14 @@ build_dot_class_method_invocation (type)
 
   s = build_string (IDENTIFIER_LENGTH (sig_id),
                    IDENTIFIER_POINTER (sig_id));
-  return build_method_invocation (build_wfl_node (classdollar_identifier_node),
-                                 build_tree_list (NULL_TREE, s));
+  t = build_method_invocation (build_wfl_node (DECL_NAME (dot_class_method)),
+                              build_tree_list (NULL_TREE, s));
+  if (DECL_CONTEXT (dot_class_method) != this_class)
+    {
+      tree class_name = DECL_NAME (TYPE_NAME (DECL_CONTEXT (dot_class_method)));
+      t = make_qualified_primary (build_wfl_node (class_name), t, 0);
+    }
+  return t;
 }
 
 /* This section of the code deals with constructor.  */
@@ -8799,8 +8789,7 @@ build_dot_class_method_invocation (type)
    necessary.  */
 
 static void
-fix_constructors (mdecl)
-     tree mdecl;
+fix_constructors (tree mdecl)
 {
   tree iii;                    /* Instance Initializer Invocation */
   tree body = DECL_FUNCTION_BODY (mdecl);
@@ -8889,13 +8878,13 @@ fix_constructors (mdecl)
       if (!found)
        compound = add_stmt_to_compound (compound, NULL_TREE,
                                          build_super_invocation (mdecl));
-      /* Explicit super() invokation should take place before the
+      /* Explicit super() invocation should take place before the
          instance initializer blocks. */
       else
        {
          compound = add_stmt_to_compound (compound, NULL_TREE,
                                           TREE_OPERAND (found_call, 0));
-         TREE_OPERAND (found_call, 0) = empty_stmt_node;
+         TREE_OPERAND (found_call, 0) = build_java_empty_stmt ();
        }
 
       DECL_INIT_CALLS_THIS (mdecl) = invokes_this;
@@ -8920,8 +8909,7 @@ fix_constructors (mdecl)
    for something that has the same signature. */
 
 static int
-verify_constructor_super (mdecl)
-     tree mdecl;
+verify_constructor_super (tree mdecl)
 {
   tree class = CLASSTYPE_SUPER (current_class);
   int super_inner = PURE_INNER_CLASS_TYPE_P (class);
@@ -8973,7 +8961,7 @@ verify_constructor_super (mdecl)
 
 static GTY(()) tree reversed_class_list;
 void
-java_expand_classes ()
+java_expand_classes (void)
 {
   int save_error_count = 0;
   static struct parser_ctxt *cur_ctxp = NULL;
@@ -8986,6 +8974,15 @@ java_expand_classes ()
 
   for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
+      tree current;
+      for (current = cur_ctxp->class_list; 
+          current; 
+          current = TREE_CHAIN (current))
+       gen_indirect_dispatch_tables (TREE_TYPE (current));
+    }
+  
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+    {
       ctxp = cur_ctxp;
       input_filename = ctxp->filename;
       lang_init_source (2);           /* Error msgs have method prototypes */
@@ -8994,9 +8991,8 @@ java_expand_classes ()
     }
   input_filename = main_input_filename;
 
-
   /* Find anonymous classes and expand their constructor. This extra pass is
-     neccessary because the constructor itself is only generated when the
+     necessary because the constructor itself is only generated when the
      method in which it is defined is expanded. */
   for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
@@ -9004,7 +9000,7 @@ java_expand_classes ()
       ctxp = cur_ctxp;
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
        {
-         current_class = TREE_TYPE (current);
+         output_class = current_class = TREE_TYPE (current);
          if (ANONYMOUS_CLASS_P (current_class))
            {
              tree d;
@@ -9012,9 +9008,7 @@ java_expand_classes ()
                {
                  if (DECL_CONSTRUCTOR_P (d))
                    {
-                     restore_line_number_status (1);
                      java_complete_expand_method (d);
-                     restore_line_number_status (0);
                      break;    /* There is only one constructor. */
                    }
                }
@@ -9022,6 +9016,59 @@ java_expand_classes ()
        }
     }
 
+  /* Expanding the constructors of anonymous classes generates access
+     methods.  Scan all the methods looking for null DECL_RESULTs --
+     this will be the case if a method hasn't been expanded.  */
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+    {
+      tree current;
+      ctxp = cur_ctxp;
+      for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
+       {
+         tree d;
+         output_class = current_class = TREE_TYPE (current);
+         for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
+           {
+             if (DECL_RESULT (d) == NULL_TREE)
+               java_complete_expand_method (d);
+           }
+       }
+    }
+
+  /* ???  Instead of all this we could iterate around the list of
+     classes until there were no more un-expanded methods.  It would
+     take a little longer -- one pass over the whole list of methods
+     -- but it would be simpler.  Like this:  */
+#if 0
+    {
+      int something_changed;
+    
+      do
+       {
+         something_changed = 0;
+         for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+           {
+             tree current;
+             ctxp = cur_ctxp;
+             for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
+               {
+                 tree d;
+                 output_class = current_class = TREE_TYPE (current);
+                 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
+                   {
+                     if (DECL_RESULT (d) == NULL_TREE)
+                       {
+                         something_changed = 1;
+                         java_complete_expand_method (d);
+                       }
+                   }
+               }
+           }
+       }
+      while (something_changed);
+    }
+#endif
+
   /* If we've found error at that stage, don't try to generate
      anything, unless we're emitting xrefs or checking the syntax only
      (but not using -fsyntax-only for the purpose of generating
@@ -9032,21 +9079,15 @@ java_expand_classes ()
 
   /* Now things are stable, go for generation of the class data. */
 
-  /* We pessimistically marked all fields external until we knew
-     what set of classes we were planning to compile.  Now mark
+  /* We pessimistically marked all methods and fields external until
+     we knew what set of classes we were planning to compile.  Now mark
      those that will be generated locally as not external.  */
   for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
       tree current;
       ctxp = cur_ctxp;
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
-       {
-         tree class = TREE_TYPE (current);
-         tree field;
-         for (field = TYPE_FIELDS (class); field ; field = TREE_CHAIN (field))
-           if (FIELD_STATIC (field))
-             DECL_EXTERNAL (field) = 0;
-       }
+       java_mark_class_local (TREE_TYPE (current));
     }
 
   /* Compile the classes.  */
@@ -9075,17 +9116,29 @@ java_expand_classes ()
           current;
           current = TREE_CHAIN (current))
        {
-         current_class = TREE_TYPE (TREE_VALUE (current));
-         outgoing_cpool = TYPE_CPOOL (current_class);
+         output_class = current_class = TREE_TYPE (TREE_VALUE (current));
          if (flag_emit_class_files)
            write_classfile (current_class);
          if (flag_emit_xref)
            expand_xref (current_class);
          else if (! flag_syntax_only)
-           {
-             java_expand_method_bodies (current_class);
-             finish_class ();
-           }
+           java_expand_method_bodies (current_class);
+       }
+    }
+}
+
+void
+java_finish_classes (void)
+{
+  static struct parser_ctxt *cur_ctxp = NULL;
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+    {
+      tree current;
+      ctxp = cur_ctxp;
+      for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
+       {
+         output_class = current_class = TREE_TYPE (current);
+         finish_class ();
        }
     }
 }
@@ -9096,9 +9149,7 @@ java_expand_classes ()
    separating `.' operator.  */
 
 static tree
-make_qualified_primary (primary, right, location)
-     tree primary, right;
-     int location;
+make_qualified_primary (tree primary, tree right, int location)
 {
   tree wfl;
 
@@ -9122,8 +9173,7 @@ make_qualified_primary (primary, right, location)
 /* Simple merge of two name separated by a `.' */
 
 static tree
-merge_qualified_name (left, right)
-     tree left, right;
+merge_qualified_name (tree left, tree right)
 {
   tree node;
   if (!left && !right)
@@ -9151,12 +9201,10 @@ merge_qualified_name (left, right)
    inherited from the location information of the `.' operator. */
 
 static tree
-make_qualified_name (left, right, location)
-     tree left, right;
-     int location;
+make_qualified_name (tree left, tree right, int location)
 {
 #ifdef USE_COMPONENT_REF
-  tree node = build (COMPONENT_REF, NULL_TREE, left, right);
+  tree node = build (COMPONENT_REF, NULL_TREE, left, right, NULL_TREE);
   EXPR_WFL_LINECOL (node) = location;
   return node;
 #else
@@ -9187,8 +9235,7 @@ make_qualified_name (left, right, location)
    last identifier is removed from the linked list */
 
 static tree
-cut_identifier_in_qualified (wfl)
-     tree wfl;
+cut_identifier_in_qualified (tree wfl)
 {
   tree q;
   tree previous = NULL_TREE;
@@ -9207,9 +9254,7 @@ cut_identifier_in_qualified (wfl)
 /* Resolve the expression name NAME. Return its decl.  */
 
 static tree
-resolve_expression_name (id, orig)
-     tree id;
-     tree *orig;
+resolve_expression_name (tree id, tree *orig)
 {
   tree name = EXPR_WFL_NODE (id);
   tree decl;
@@ -9237,6 +9282,8 @@ resolve_expression_name (id, orig)
              if (FIELD_LOCAL_ALIAS_USED (decl))
                name = DECL_NAME (decl);
 
+             check_deprecation (id, decl);
+
              /* Instance variable (8.3.1.1) can't appear within
                 static method, static initializer or initializer for
                 a static variable. */
@@ -9279,6 +9326,12 @@ resolve_expression_name (id, orig)
              /* We may be asked to save the real field access node */
              if (orig)
                *orig = access;
+             /* Last check: can we access the field? */
+             if (not_accessible_p (current_class, decl, NULL_TREE, 0))
+               {
+                 not_accessible_field_error (id, decl);
+                 return error_mark_node;
+               }
              /* And we return what we got */
              return access;
            }
@@ -9311,8 +9364,7 @@ resolve_expression_name (id, orig)
 }
 
 static void
-static_ref_err (wfl, field_id, class_type)
-    tree wfl, field_id, class_type;
+static_ref_err (tree wfl, tree field_id, tree class_type)
 {
   parse_error_context
     (wfl,
@@ -9327,13 +9379,11 @@ static_ref_err (wfl, field_id, class_type)
    recipient's address can be null. */
 
 static tree
-resolve_field_access (qual_wfl, field_decl, field_type)
-     tree qual_wfl;
-     tree *field_decl, *field_type;
+resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
 {
   int is_static = 0;
   tree field_ref;
-  tree decl, where_found, type_found;
+  tree decl = NULL_TREE, where_found, type_found;
 
   if (resolve_qualified_expression_name (qual_wfl, &decl,
                                         &where_found, &type_found))
@@ -9375,6 +9425,19 @@ resolve_field_access (qual_wfl, field_decl, field_type)
        return error_mark_node;
       if (is_static)
        field_ref = maybe_build_class_init_for_field (decl, field_ref);
+
+      /* If we're looking at a static field, we may need to generate a
+        class initialization for it.  This can happen when the access
+        looks like `field.ref', where `field' is a static field in an
+        interface we implement.  */
+      if (!flag_emit_class_files
+         && !flag_emit_xref
+         && TREE_CODE (where_found) == VAR_DECL
+         && FIELD_STATIC (where_found))
+       {
+         build_static_field_ref (where_found);
+         field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
+       }
     }
   else
     field_ref = decl;
@@ -9392,8 +9455,7 @@ resolve_field_access (qual_wfl, field_decl, field_type)
    NODE. */
 
 static tree
-strip_out_static_field_access_decl (node)
-    tree node;
+strip_out_static_field_access_decl (tree node)
 {
   if (TREE_CODE (node) == COMPOUND_EXPR)
     {
@@ -9416,9 +9478,8 @@ strip_out_static_field_access_decl (node)
 /* 6.5.5.2: Qualified Expression Names */
 
 static int
-resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
-     tree wfl;
-     tree *found_decl, *type_found, *where_found;
+resolve_qualified_expression_name (tree wfl, tree *found_decl,
+                                  tree *where_found, tree *type_found)
 {
   int from_type = 0;           /* Field search initiated from a type */
   int from_super = 0, from_cast = 0, from_qualified_this = 0;
@@ -9515,11 +9576,14 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
             instantiation using a primary qualified by a `new' */
          RESTORE_THIS_AND_CURRENT_CLASS;
 
-         /* EH check. No check on access$<n> functions */
-         if (location
-             && !OUTER_FIELD_ACCESS_IDENTIFIER_P
-                   (DECL_NAME (current_function_decl)))
-           check_thrown_exceptions (location, ret_decl);
+         if (location)
+           {
+             tree arguments = NULL_TREE;
+             if (TREE_CODE (qual_wfl) == CALL_EXPR
+                 && TREE_OPERAND (qual_wfl, 1) != NULL_TREE)
+               arguments = TREE_VALUE (TREE_OPERAND (qual_wfl, 1));
+             check_thrown_exceptions (location, ret_decl, arguments);
+           }
 
          /* If the previous call was static and this one is too,
             build a compound expression to hold the two (because in
@@ -9692,6 +9756,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
              tree list;
              *where_found = decl;
 
+             check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
+
              /* We want to be absolutely sure that the class is laid
                  out. We're going to search something inside it. */
              *type_found = type = TREE_TYPE (decl);
@@ -9704,7 +9770,6 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
                  list = TREE_CHAIN (q);
                  while (list)
                    {
-                     RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
                      RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
                      list = TREE_CHAIN (list);
                    }
@@ -9733,8 +9798,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
          decl = QUAL_RESOLUTION (q);
 
          /* Sneak preview. If next we see a `new', we're facing a
-            qualification with resulted in a type being selected
-            instead of a field.  Report the error */
+            qualification which resulted in a type being selected
+            instead of a field.  Report the error */
          if(TREE_CHAIN (q)
             && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
            {
@@ -9743,16 +9808,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
              return 1;
            }
 
-         if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
-           {
-             parse_error_context
-               (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
-                java_accstring_lookup (get_access_flags_from_decl (decl)),
-                GET_TYPE_NAME (type),
-                IDENTIFIER_POINTER (DECL_NAME (decl)),
-                IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
-             return 1;
-           }
+         check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
+          
          check_deprecation (qual_wfl, decl);
 
          type = TREE_TYPE (decl);
@@ -9794,7 +9851,7 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
                }
            }
 
-         /* Report and error if we're using a numerical litteral as a
+         /* Report and error if we're using a numerical literal as a
              qualifier. It can only be an INTEGER_CST. */
          else if (TREE_CODE (qual_wfl) == INTEGER_CST)
            {
@@ -9872,19 +9929,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
 
              /* Check on accessibility here */
              if (not_accessible_p (current_class, field_decl,
-                                   DECL_CONTEXT (field_decl), from_super))
-               {
-                 parse_error_context
-                   (qual_wfl,
-                    "Can't access %s field `%s.%s' from `%s'",
-                    java_accstring_lookup
-                      (get_access_flags_from_decl (field_decl)),
-                    GET_TYPE_NAME (type),
-                    IDENTIFIER_POINTER (DECL_NAME (field_decl)),
-                    IDENTIFIER_POINTER
-                      (DECL_NAME (TYPE_NAME (current_class))));
-                 return 1;
-               }
+                                   *type_found, from_super))
+               return not_accessible_field_error (qual_wfl,field_decl);    
              check_deprecation (qual_wfl, field_decl);
 
              /* There are things to check when fields are accessed
@@ -9966,16 +10012,16 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
    method.  */
 
 static int
-not_accessible_p (reference, member, where, from_super)
-     tree reference, member;
-     tree where;
-     int from_super;
+not_accessible_p (tree reference, tree member, tree where, int from_super)
 {
   int access_flag = get_access_flags_from_decl (member);
-
-  /* Inner classes are processed by check_inner_class_access */
-  if (INNER_CLASS_TYPE_P (reference))
-    return 0;
+  bool is_static = false;
+  if (TREE_CODE (member) == FIELD_DECL ||
+      TREE_CODE (member) == VAR_DECL)
+    is_static = FIELD_STATIC (member);
+  else
+    is_static = METHOD_STATIC (member);
 
   /* Access always granted for members declared public */
   if (access_flag & ACC_PUBLIC)
@@ -9994,26 +10040,34 @@ not_accessible_p (reference, member, where, from_super)
       if (from_super)
        return 0;
 
-      /* If where is active, access was made through a
-        qualifier. Access is granted if the type of the qualifier is
-        or is a sublass of the type the access made from (6.6.2.1.)  */
-      if (where && !inherits_from_p (reference, where))
-       return 1;
-
-      /* Otherwise, access is granted if occurring from the class where
-        member is declared or a subclass of it. Find the right
-        context to perform the check */
-      if (PURE_INNER_CLASS_TYPE_P (reference))
+      /* If WHERE is active, access was made through a qualifier. For 
+         non-static members, access is granted if the type of the qualifier 
+        is or is a sublass of the type the access is made from (6.6.2.1.)  */
+      if (where && !is_static)
         {
-          while (INNER_CLASS_TYPE_P (reference))
+         while (reference)
             {
-              if (inherits_from_p (reference, DECL_CONTEXT (member)))
-                return 0;
-              reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
-            }
+             if (inherits_from_p (where, reference))
+               return 0;
+             if (PURE_INNER_CLASS_TYPE_P (reference))
+               reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
+             else
+               break;
+           }
+         return 1;
+       }
+
+      /* Otherwise, access is granted if occurring from within the class
+         where member is declared, or a subclass of it.  */
+      while (reference)
+        {
+          if (inherits_from_p (reference, DECL_CONTEXT (member)))
+            return 0;
+         if (PURE_INNER_CLASS_TYPE_P (reference))
+            reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
+         else
+           break;
         }
-      if (inherits_from_p (reference, DECL_CONTEXT (member)))
-       return 0;
       return 1;
     }
 
@@ -10022,44 +10076,55 @@ not_accessible_p (reference, member, where, from_super)
      it for innerclasses too. */
   if (access_flag & ACC_PRIVATE)
     {
-      if (reference == DECL_CONTEXT (member))
-       return 0;
-      if (enclosing_context_p (reference, DECL_CONTEXT (member)))
+      if (reference == DECL_CONTEXT (member) ||
+          common_enclosing_context_p (DECL_CONTEXT (member), reference))
        return 0;
       return 1;
     }
 
-  /* Default access are permitted only when occurring within the
-     package in which the type (REFERENCE) is declared. In other words,
-     REFERENCE is defined in the current package */
-  if (ctxp->package)
-    return !class_in_current_package (reference);
-
-  /* Otherwise, access is granted */
-  return 0;
+  /* Default access is permitted only when occurring from within the
+     package in which the context (MEMBER) is declared.  */
+  return !class_in_current_package (DECL_CONTEXT (member));
 }
 
 /* Test deprecated decl access.  */
 static void
-check_deprecation (wfl, decl)
-     tree wfl, decl;
+check_deprecation (tree wfl, tree decl)
 {
-  const char *file = DECL_SOURCE_FILE (decl);
+  const char *file;
+  tree elt;
+
+  if (! flag_deprecated)
+    return;
+
+  /* We want to look at the element type of arrays here, so we strip
+     all surrounding array types.  */
+  if (TYPE_ARRAY_P (TREE_TYPE (decl)))
+    {
+      elt = TREE_TYPE (decl);
+      while (TYPE_ARRAY_P (elt))
+       elt = TYPE_ARRAY_ELEMENT (elt);
+      /* We'll end up with a pointer type, so we use TREE_TYPE to go
+        to the record.  */
+      decl = TYPE_NAME (TREE_TYPE (elt));
+    }
+  file = DECL_SOURCE_FILE (decl);
+
   /* Complain if the field is deprecated and the file it was defined
      in isn't compiled at the same time the file which contains its
      use is */
   if (DECL_DEPRECATED (decl)
       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
     {
-      char the [20];
+      const char *the;
       switch (TREE_CODE (decl))
        {
        case FUNCTION_DECL:
-         strcpy (the, "method");
+         the = "method";
          break;
        case FIELD_DECL:
        case VAR_DECL:
-         strcpy (the, "field");
+         the = "field";
          break;
        case TYPE_DECL:
          parse_warning_context (wfl, "The class `%s' has been deprecated",
@@ -10082,8 +10147,7 @@ check_deprecation (wfl, decl)
 
 static GTY(()) tree cicp_cache;
 static int
-class_in_current_package (class)
-     tree class;
+class_in_current_package (tree class)
 {
   int qualified_flag;
   tree left;
@@ -10106,7 +10170,7 @@ class_in_current_package (class)
     return 1;
 
   /* Compare the left part of the name of CLASS with the package name */
-  breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
+  split_qualified_name (&left, NULL, DECL_NAME (TYPE_NAME (class)));
   if (ctxp->package == left)
     {
       cicp_cache = class;
@@ -10119,8 +10183,7 @@ class_in_current_package (class)
    done only if certain conditions meet.  */
 
 static tree
-maybe_access_field (decl, where, type)
-  tree decl, where, type;
+maybe_access_field (tree decl, tree where, tree type)
 {
   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
       && !FIELD_STATIC (decl))
@@ -10135,12 +10198,8 @@ maybe_access_field (decl, where, type)
    used. IS_STATIC is set to 1 if the invoked function is static. */
 
 static tree
-patch_method_invocation (patch, primary, where, from_super,
-                        is_static, ret_decl)
-     tree patch, primary, where;
-     int from_super;
-     int *is_static;
-     tree *ret_decl;
+patch_method_invocation (tree patch, tree primary, tree where, int from_super,
+                        int *is_static, tree *ret_decl)
 {
   tree wfl = TREE_OPERAND (patch, 0);
   tree args = TREE_OPERAND (patch, 1);
@@ -10151,7 +10210,7 @@ patch_method_invocation (patch, primary, where, from_super,
   tree this_arg = NULL_TREE;
   int is_array_clone_call = 0;
 
-  /* Should be overriden if everything goes well. Otherwise, if
+  /* Should be overridden if everything goes well. Otherwise, if
      something fails, it should keep this value. It stop the
      evaluation of a bogus assignment. See java_complete_tree,
      MODIFY_EXPR: for the reasons why we sometimes want to keep on
@@ -10370,7 +10429,7 @@ patch_method_invocation (patch, primary, where, from_super,
          this_arg = primary ? primary : current_this;
 
          /* If we're using an access method, things are different.
-            There are two familly of cases:
+            There are two family of cases:
 
             1) We're not generating bytecodes:
 
@@ -10386,7 +10445,7 @@ patch_method_invocation (patch, primary, where, from_super,
             - LIST is static. It's invocation is transformed from
               x(a1,....,an) into TYPE_OF(this$<n>).x(a1,....an).
 
-            Of course, this$<n> can be abitrary complex, ranging from
+            Of course, this$<n> can be arbitrarily complex, ranging from
             this$0 (the immediate outer context) to
             access$0(access$0(...(this$0))).
 
@@ -10418,15 +10477,13 @@ patch_method_invocation (patch, primary, where, from_super,
     {
       const char *const fct_name = IDENTIFIER_POINTER (DECL_NAME (list));
       const char *const access =
-       java_accstring_lookup (get_access_flags_from_decl (list));
+       accessibility_string (get_access_flags_from_decl (list));
       const char *const klass =
        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list))));
       const char *const refklass =
        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)));
       const char *const what = (DECL_CONSTRUCTOR_P (list)
                                ? "constructor" : "method");
-      /* FIXME: WFL yields the wrong message here but I don't know
-        what else to use.  */
       parse_error_context (wfl,
                           "Can't access %s %s `%s.%s' from `%s'",
                           access, what, klass, fct_name, refklass);
@@ -10434,11 +10491,10 @@ patch_method_invocation (patch, primary, where, from_super,
     }
 
   /* Deprecation check: check whether the method being invoked or the
-     instance-being-created's type are deprecated. */
+     instance-being-created's type are deprecated.  */
   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
     check_deprecation (wfl, TYPE_NAME (DECL_CONTEXT (list)));
-  else
-    check_deprecation (wfl, list);
+  check_deprecation (wfl, list);
 
   /* If invoking a innerclass constructor, there are hidden parameters
      to pass */
@@ -10549,8 +10605,8 @@ patch_method_invocation (patch, primary, where, from_super,
    non static method. Return 1 if it's the case, 0 otherwise. */
 
 static int
-check_for_static_method_reference (wfl, node, method, where, primary)
-     tree wfl, node, method, where, primary;
+check_for_static_method_reference (tree wfl, tree node, tree method,
+                                  tree where, tree primary)
 {
   if (METHOD_STATIC (current_function_decl)
       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
@@ -10572,9 +10628,7 @@ check_for_static_method_reference (wfl, node, method, where, primary)
    returned.  */
 
 static int
-maybe_use_access_method (is_super_init, mdecl, this_arg)
-     int is_super_init;
-     tree *mdecl, *this_arg;
+maybe_use_access_method (int is_super_init, tree *mdecl, tree *this_arg)
 {
   tree ctx;
   tree md = *mdecl, ta = *this_arg;
@@ -10631,8 +10685,8 @@ maybe_use_access_method (is_super_init, mdecl, this_arg)
   *mdecl = md;
   *this_arg = ta;
 
-  /* Returnin a nonzero value indicates we were doing a non static
-     method invokation that is now a static invocation. It will have
+  /* Returning a nonzero value indicates we were doing a non static
+     method invocation that is now a static invocation. It will have
      callee displace `this' to insert it in the regular argument
      list. */
   return (non_static_context && to_return);
@@ -10642,8 +10696,7 @@ maybe_use_access_method (is_super_init, mdecl, this_arg)
    mode.  */
 
 static tree
-patch_invoke (patch, method, args)
-     tree patch, method, args;
+patch_invoke (tree patch, tree method, tree args)
 {
   tree dtable, func;
   tree original_call, t, ta;
@@ -10662,7 +10715,7 @@ patch_invoke (patch, method, args)
        TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
 
-  /* Resolve unresolved returned type isses */
+  /* Resolve unresolved returned type issues */
   t = TREE_TYPE (TREE_TYPE (method));
   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
     resolve_and_layout (TREE_TYPE (t), NULL);
@@ -10745,11 +10798,9 @@ patch_invoke (patch, method, args)
        (class_has_finalize_method (class) ? alloc_object_node
                                           : alloc_no_finalizer_node);
       new = build (CALL_EXPR, promote_type (class),
-                  build_address_of (alloc_node),
-                  tree_cons (NULL_TREE, build_class_ref (class),
-                             build_tree_list (NULL_TREE,
-                                              size_in_bytes (class))),
-                  NULL_TREE);
+                    build_address_of (alloc_node),
+                    build_tree_list (NULL_TREE, build_class_ref (class)),
+                    NULL_TREE);
       saved_new = save_expr (new);
       c1 = build_tree_list (NULL_TREE, saved_new);
       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
@@ -10785,10 +10836,10 @@ patch_invoke (patch, method, args)
       /* We have to call force_evaluation_order now because creating a
         COMPOUND_EXPR wraps the arg list in a way that makes it
         unrecognizable by force_evaluation_order later.  Yuk.  */
-      tree save = save_expr (force_evaluation_order (patch));
+      tree save = force_evaluation_order (patch);
       tree type = TREE_TYPE (patch);
 
-      patch = build (COMPOUND_EXPR, type, save, empty_stmt_node);
+      patch = build (COMPOUND_EXPR, type, save, build_java_empty_stmt ());
       list = tree_cons (method, patch,
                        DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl));
 
@@ -10801,9 +10852,7 @@ patch_invoke (patch, method, args)
 }
 
 static int
-invocation_mode (method, super)
-     tree method;
-     int super;
+invocation_mode (tree method, int super)
 {
   int access = get_access_flags_from_decl (method);
 
@@ -10834,10 +10883,7 @@ invocation_mode (method, super)
    15.11.2 (Compile-Time Step 2) */
 
 static tree
-lookup_method_invoke (lc, cl, class, name, arg_list)
-     int lc;
-     tree cl;
-     tree class, name, arg_list;
+lookup_method_invoke (int lc, tree cl, tree class, tree name, tree arg_list)
 {
   tree atl = end_params_node;          /* Arg Type List */
   tree method, signature, list, node;
@@ -10920,13 +10966,14 @@ lookup_method_invoke (lc, cl, class, name, arg_list)
    when we're looking for a constructor. */
 
 static tree
-find_applicable_accessible_methods_list (lc, class, name, arglist)
-     int lc;
-     tree class, name, arglist;
+find_applicable_accessible_methods_list (int lc, tree class, tree name,
+                                        tree arglist)
 {
   static htab_t searched_classes;
   static int search_not_done = 0;
   tree list = NULL_TREE, all_list = NULL_TREE;
+  tree base_binfo;
+  int i;
 
   /* Check the hash table to determine if this class has been searched
      already. */
@@ -10944,7 +10991,7 @@ find_applicable_accessible_methods_list (lc, class, name, arglist)
   search_not_done++;
   *htab_find_slot (searched_classes, class, INSERT) = class;
 
-  if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
+  if (!CLASS_LOADED_P (class))
     {
       load_class (class, 1);
       safe_layout_class (class);
@@ -10954,16 +11001,13 @@ find_applicable_accessible_methods_list (lc, class, name, arglist)
   if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
       && CLASS_INTERFACE (TYPE_NAME (class)))
     {
-      int i, n;
-      tree basetype_vec = TYPE_BINFO_BASETYPES (class);
       search_applicable_methods_list (lc, TYPE_METHODS (class),
                                      name, arglist, &list, &all_list);
-      n = TREE_VEC_LENGTH (basetype_vec);
-      for (i = 1; i < n; i++)
+      for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
        {
-         tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+         tree t = BINFO_TYPE (base_binfo);
          tree rlist;
-
+         
          rlist = find_applicable_accessible_methods_list (lc,  t, name,
                                                           arglist);
          list = chainon (rlist, list);
@@ -10987,21 +11031,20 @@ find_applicable_accessible_methods_list (lc, class, name, arglist)
 
       /* We must search all interfaces of this class */
       if (!lc)
-      {
-       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
-       int n = TREE_VEC_LENGTH (basetype_vec), i;
-       for (i = 1; i < n; i++)
-         {
-           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
-           if (t != object_type_node)
-             {
-               tree rlist
-                 = find_applicable_accessible_methods_list (lc, t,
-                                                            name, arglist);
-               list = chainon (rlist, list);
-             }
-         }
-      }
+       {
+         for (i = 1;
+              BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+           {
+             tree t = BINFO_TYPE (base_binfo);
+             if (t != object_type_node)
+               {
+                 tree rlist
+                   = find_applicable_accessible_methods_list (lc, t,
+                                                              name, arglist);
+                 list = chainon (rlist, list);
+               }
+           }
+       }
 
       /* Search superclass */
       if (!lc && CLASSTYPE_SUPER (class) != NULL_TREE)
@@ -11040,10 +11083,8 @@ find_applicable_accessible_methods_list (lc, class, name, arglist)
 /* Effectively search for the appropriate method in method */
 
 static void
-search_applicable_methods_list (lc, method, name, arglist, list, all_list)
-     int lc;
-     tree method, name, arglist;
-     tree *list, *all_list;
+search_applicable_methods_list (int lc, tree method, tree name, tree arglist,
+                               tree *list, tree *all_list)
 {
   for (; method; method = TREE_CHAIN (method))
     {
@@ -11071,8 +11112,7 @@ search_applicable_methods_list (lc, method, name, arglist, list, all_list)
 /* 15.11.2.2 Choose the Most Specific Method */
 
 static tree
-find_most_specific_methods_list (list)
-     tree list;
+find_most_specific_methods_list (tree list)
 {
   int max = 0;
   int abstract, candidates;
@@ -11121,10 +11161,15 @@ find_most_specific_methods_list (list)
 
   /* If we have several and they're all abstract, just pick the
      closest one. */
-  if (candidates > 0 && (candidates == abstract))
+  if (candidates > 0 && candidates == abstract)
     {
+      /* FIXME: merge the throws clauses.  There is no convenient way
+        to do this in gcj right now, since ideally we'd like to
+        introduce a new METHOD_DECL here, but that is really not
+        possible.  */
       new_list = nreverse (new_list);
       TREE_CHAIN (new_list) = NULL_TREE;
+      return new_list;
     }
 
   /* We have several (we couldn't find a most specific), all but one
@@ -11162,10 +11207,9 @@ static GTY(()) tree m2_arg_value;
 static GTY(()) tree m2_arg_cache;
 
 static int
-argument_types_convertible (m1, m2_or_arglist)
-    tree m1, m2_or_arglist;
+argument_types_convertible (tree m1, tree m2_or_arglist)
 {
-  register tree m1_arg, m2_arg;
+  tree m1_arg, m2_arg;
 
   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
 
@@ -11202,293 +11246,76 @@ argument_types_convertible (m1, m2_or_arglist)
 
 /* Qualification routines */
 
+/* Given a name x.y.z, look up x locally.  If it's found, save the
+   decl.  If it's not found, mark the name as RESOLVE_PACKAGE_NAME_P,
+   so that we later try and load the appropriate classes.  */
 static void
-qualify_ambiguous_name (id)
-     tree id;
-{
-  tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
-    saved_current_class;
-  int again, super_found = 0, this_found = 0, new_array_found = 0;
-  int code;
-
-  /* We first qualify the first element, then derive qualification of
-     others based on the first one. If the first element is qualified
-     by a resolution (field or type), this resolution is stored in the
-     QUAL_RESOLUTION of the qual element being examined. We need to
-     save the current_class since the use of SUPER might change the
-     its value. */
-  saved_current_class = current_class;
-  qual = EXPR_WFL_QUALIFICATION (id);
-  do {
-
-    /* Simple qualified expression feature a qual_wfl that is a
-       WFL. Expression derived from a primary feature more complicated
-       things like a CALL_EXPR. Expression from primary need to be
-       worked out to extract the part on which the qualification will
-       take place. */
-    qual_wfl = QUAL_WFL (qual);
-    switch (TREE_CODE (qual_wfl))
-      {
-      case CALL_EXPR:
-       qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION
-           || (EXPR_WFL_QUALIFICATION (qual_wfl)
-               && TREE_CODE (EXPR_WFL_QUALIFICATION (qual_wfl)) == TREE_LIST))
-         {
-           qual = EXPR_WFL_QUALIFICATION (qual_wfl);
-           qual_wfl = QUAL_WFL (qual);
-         }
-       break;
-      case NEW_ARRAY_EXPR:
-      case NEW_ANONYMOUS_ARRAY_EXPR:
-       qual = TREE_CHAIN (qual);
-       again = new_array_found = 1;
-       continue;
-      case CONVERT_EXPR:
-       break;
-      case NEW_CLASS_EXPR:
-       qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       break;
-      case ARRAY_REF:
-       while (TREE_CODE (qual_wfl) == ARRAY_REF)
-         qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       break;
-      case STRING_CST:
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       break;
-      case CLASS_LITERAL:
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-      break;
-      default:
-       /* Fix for -Wall. Just break doing nothing */
-       break;
-      }
-
-    ptr_type = current_class;
-    again = 0;
-    code = TREE_CODE (qual_wfl);
-
-    /* Pos evaluation: non WFL leading expression nodes */
-    if (code == CONVERT_EXPR
-       && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
-      name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
-
-    else if (code == INTEGER_CST)
-      name = qual_wfl;
-
-    else if (code == CONVERT_EXPR &&
-            TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
-      name = TREE_OPERAND (qual_wfl, 0);
-
-    else if (code == CONVERT_EXPR
-            && TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == CALL_EXPR
-            && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (qual_wfl, 0), 0))
-                == EXPR_WITH_FILE_LOCATION))
-      name = TREE_OPERAND (TREE_OPERAND (qual_wfl, 0), 0);
+qualify_ambiguous_name (tree id)
+{
+  tree name, decl;
 
-    else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
-            TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
-      name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
+  /* We inspect the first item of the qualification list.  As a sanity
+     check, make sure that it is an identfier node.  */
+  tree qual = EXPR_WFL_QUALIFICATION (id);
+  tree qual_wfl = QUAL_WFL (qual);
 
-    else if (code == TREE_LIST)
-      name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
+  if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
+    return;
 
-    else if (code == STRING_CST || code == CONDITIONAL_EXPR
-            || code == PLUS_EXPR)
-      {
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       again = 1;
-      }
-    else
-      {
-       name = EXPR_WFL_NODE (qual_wfl);
-       if (!name)
-         {
-           qual = EXPR_WFL_QUALIFICATION (qual_wfl);
-           again = 1;
-         }
-      }
+  name = EXPR_WFL_NODE (qual_wfl);
 
-    /* If we have a THIS (from a primary), we set the context accordingly */
-    if (name == this_identifier_node)
-      {
-       /* This isn't really elegant. One more added irregularity
-          before I start using COMPONENT_REF (hopefully very soon.)  */
-       if (TREE_CODE (TREE_PURPOSE (qual)) == ARRAY_REF
-           && TREE_CODE (TREE_OPERAND (TREE_PURPOSE (qual), 0)) ==
-              EXPR_WITH_FILE_LOCATION
-           && EXPR_WFL_NODE (TREE_OPERAND (TREE_PURPOSE (qual), 0)) ==
-              this_identifier_node)
-           {
-             qual = TREE_OPERAND (TREE_PURPOSE (qual), 0);
-             qual = EXPR_WFL_QUALIFICATION (qual);
-           }
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       if (TREE_CODE (qual_wfl) == CALL_EXPR)
-         again = 1;
-       else if (TREE_CODE (qual_wfl) == EXPR_WITH_FILE_LOCATION)
-         name = EXPR_WFL_NODE (qual_wfl);
-       else if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
-         name = TREE_OPERAND (qual_wfl, 0);
-       this_found = 1;
-      }
-    /* If we have a SUPER, we set the context accordingly */
-    if (name == super_identifier_node)
-      {
-       current_class = CLASSTYPE_SUPER (ptr_type);
-       /* Check that there is such a thing as a super class. If not,
-          return.  The error will be caught later on, during the
-          resolution */
-       if (!current_class)
-         {
-           current_class = saved_current_class;
-           return;
-         }
-       qual = TREE_CHAIN (qual);
-       /* Do one more interation to set things up */
-       super_found = again = 1;
-      }
-  } while (again);
+  /* If we don't have an identifier, or we have a 'this' or 'super',
+     then field access processing is all we need : there is nothing
+     for us to do.  */
+  if (!name || TREE_CODE (name) != IDENTIFIER_NODE ||
+      name == this_identifier_node ||
+      name == super_identifier_node)
+    return;
 
   /* If name appears within the scope of a local variable declaration
-     or parameter declaration, then it is an expression name. We don't
-     carry this test out if we're in the context of the use of SUPER
-     or THIS */
-  if (!this_found && !super_found
-      && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
-      && (decl = IDENTIFIER_LOCAL_VALUE (name)))
-    {
-      RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
+     or parameter declaration, or is a field within an enclosing
+     class, then it is an expression name.  Save the decl and let
+     resolve_field_access do it's work.  */
+  if ((decl = IDENTIFIER_LOCAL_VALUE (name)) ||
+      (decl = lookup_field_wrapper (current_class, name)))
+    {
       QUAL_RESOLUTION (qual) = decl;
+      return;
     }
 
-  /* If within the class/interface NAME was found to be used there
-     exists a (possibly inherited) field named NAME, then this is an
-     expression name. If we saw a NEW_ARRAY_EXPR before and want to
-     address length, it is OK. */
-  else if ((decl = lookup_field_wrapper (ptr_type, name))
-          || name == length_identifier_node)
-    {
-      RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
-      QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
-    }
-
-  /* We reclassify NAME as yielding to a type name resolution if:
-     - NAME is a class/interface declared within the compilation
-       unit containing NAME,
-     - NAME is imported via a single-type-import declaration,
-     - NAME is declared in an another compilation unit of the package
-       of the compilation unit containing NAME,
-     - NAME is declared by exactly on type-import-on-demand declaration
-     of the compilation unit containing NAME.
-     - NAME is actually a STRING_CST.
-     This can't happen if the expression was qualified by `this.' */
-  else if (! this_found &&
-          (TREE_CODE (name) == STRING_CST ||
-           TREE_CODE (name) == INTEGER_CST ||
-           (decl = resolve_and_layout (name, NULL_TREE))))
+  /* If name is a known class name (either declared or imported), mark
+     us as a type name.  */
+  if ((decl = resolve_and_layout (name, NULL_TREE)))
     {
       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
       QUAL_RESOLUTION (qual) = decl;
     }
 
-  /* Method call, array references and cast are expression name */
-  else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
-          || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
-          || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR
-          || TREE_CODE (QUAL_WFL (qual)) == MODIFY_EXPR)
-    RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
-
   /* Check here that NAME isn't declared by more than one
      type-import-on-demand declaration of the compilation unit
      containing NAME. FIXME */
 
-  /* Otherwise, NAME is reclassified as a package name */
+  /* We couldn't find a declaration for the name.  Assume for now that
+     we have a qualified class name that needs to be loaded from an
+     external class file.  */
   else
     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
 
-  /* Propagate the qualification accross other components of the
+  /* Propagate the qualification across other components of the
      qualified name */
   for (qual = TREE_CHAIN (qual); qual;
        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
     {
       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
        RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
-      else
-       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
     }
 
   /* Store the global qualification for the ambiguous part of ID back
      into ID fields */
-  if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
-    RESOLVE_EXPRESSION_NAME_P (id) = 1;
-  else if (RESOLVE_TYPE_NAME_P (qual_wfl))
+  if (RESOLVE_TYPE_NAME_P (qual_wfl))
     RESOLVE_TYPE_NAME_P (id) = 1;
   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
     RESOLVE_PACKAGE_NAME_P (id) = 1;
-
-  /* Restore the current class */
-  current_class = saved_current_class;
-}
-
-static int
-breakdown_qualified (left, right, source)
-    tree *left, *right, source;
-{
-  char *p, *base;
-  int l = IDENTIFIER_LENGTH (source);
-
-  base = alloca (l + 1);
-  memcpy (base, IDENTIFIER_POINTER (source), l + 1);
-
-  /* Breakdown NAME into REMAINDER . IDENTIFIER.  */
-  p = base + l - 1;
-  while (*p != '.' && p != base)
-    p--;
-
-  /* We didn't find a '.'. Return an error.  */
-  if (p == base)
-    return 1;
-
-  *p = '\0';
-  if (right)
-    *right = get_identifier (p+1);
-  *left = get_identifier (base);
-
-  return 0;
-}
-
-/* Return TRUE if two classes are from the same package. */
-
-static int
-in_same_package (name1, name2)
-  tree name1, name2;
-{
-  tree tmp;
-  tree pkg1;
-  tree pkg2;
-
-  if (TREE_CODE (name1) == TYPE_DECL)
-    name1 = DECL_NAME (name1);
-  if (TREE_CODE (name2) == TYPE_DECL)
-    name2 = DECL_NAME (name2);
-
-  if (QUALIFIED_P (name1) != QUALIFIED_P (name2))
-    /* One in empty package. */
-    return 0;
-
-  if (QUALIFIED_P (name1) == 0 && QUALIFIED_P (name2) == 0)
-    /* Both in empty package. */
-    return 1;
-
-  breakdown_qualified (&pkg1, &tmp, name1);
-  breakdown_qualified (&pkg2, &tmp, name2);
-
-  return (pkg1 == pkg2);
 }
 
 /* Patch tree nodes in a function body. When a BLOCK is found, push
@@ -11496,8 +11323,7 @@ in_same_package (name1, name2)
    Same as java_complete_lhs, but does resolve static finals to values. */
 
 static tree
-java_complete_tree (node)
-     tree node;
+java_complete_tree (tree node)
 {
   node = java_complete_lhs (node);
   if (JDECL_P (node) && CLASS_FINAL_VARIABLE_P (node)
@@ -11512,8 +11338,7 @@ java_complete_tree (node)
 }
 
 static tree
-java_stabilize_reference (node)
-     tree node;
+java_stabilize_reference (tree node)
 {
   if (TREE_CODE (node) == COMPOUND_EXPR)
     {
@@ -11531,8 +11356,7 @@ java_stabilize_reference (node)
    Same as java_complete_tree, but does not resolve static finals to values. */
 
 static tree
-java_complete_lhs (node)
-     tree node;
+java_complete_lhs (tree node)
 {
   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
   int flag;
@@ -11588,12 +11412,12 @@ java_complete_lhs (node)
              long blocks. */
          ptr = &BLOCK_EXPR_BODY (node);
          while (TREE_CODE (*ptr) == COMPOUND_EXPR
-                && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
+                && !IS_EMPTY_STMT (TREE_OPERAND (*ptr, 1)))
            {
              tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
              tree *next = &TREE_OPERAND (*ptr, 1);
              TREE_OPERAND (*ptr, 0) = cur;
-             if (cur == empty_stmt_node)
+             if (IS_EMPTY_STMT (cur))
                {
                  /* Optimization;  makes it easier to detect empty bodies.
                     Most useful for <clinit> with all-constant initializer. */
@@ -11618,6 +11442,8 @@ java_complete_lhs (node)
                      && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
                    unreachable_stmt_error (*ptr);
                }
+             if (TREE_TYPE (*ptr) == NULL_TREE)
+               TREE_TYPE (*ptr) = void_type_node;
              ptr = next;
            }
          *ptr = java_complete_tree (*ptr);
@@ -11652,9 +11478,11 @@ java_complete_lhs (node)
     case TRY_FINALLY_EXPR:
       COMPLETE_CHECK_OP_0 (node);
       COMPLETE_CHECK_OP_1 (node);
-      if (TREE_OPERAND (node, 0) == empty_stmt_node)
+      if (IS_EMPTY_STMT (TREE_OPERAND (node, 0)))
+       /* Reduce try/finally nodes with an empty try block.  */
        return TREE_OPERAND (node, 1);
-      if (TREE_OPERAND (node, 1) == empty_stmt_node)
+      if (IS_EMPTY_STMT (TREE_OPERAND (node, 1)))
+       /* Likewise for an empty finally block.  */
        return TREE_OPERAND (node, 0);
       CAN_COMPLETE_NORMALLY (node)
        = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
@@ -11669,7 +11497,7 @@ java_complete_lhs (node)
       TREE_TYPE (node) = void_type_node;
       POP_LABELED_BLOCK ();
 
-      if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
+      if (IS_EMPTY_STMT (LABELED_BLOCK_BODY (node)))
        {
          LABELED_BLOCK_BODY (node) = NULL_TREE;
          CAN_COMPLETE_NORMALLY (node) = 1;
@@ -11700,7 +11528,8 @@ java_complete_lhs (node)
                                       TREE_OPERAND (cn, 1));
        }
       /* Accept final locals too. */
-      else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn))
+      else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn) 
+              && DECL_INITIAL (cn))
        cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
 
       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
@@ -11825,7 +11654,7 @@ java_complete_lhs (node)
       wfl_op2 = TREE_OPERAND (node, 1);
       TREE_OPERAND (node, 0) = nn =
        java_complete_tree (TREE_OPERAND (node, 0));
-      if (wfl_op2 == empty_stmt_node)
+      if (IS_EMPTY_STMT (wfl_op2))
        CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
       else
        {
@@ -11836,7 +11665,9 @@ java_complete_lhs (node)
              nn = wfl_op2;
              if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
                nn = EXPR_WFL_NODE (nn);
-             if (TREE_CODE (nn) != EXIT_EXPR)
+             /* NN can be NULL_TREE exactly when UPDATE is, in
+                finish_for_loop.  */
+             if (nn != NULL_TREE && TREE_CODE (nn) != EXIT_EXPR)
                {
                  SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
                  if (SUPPRESS_UNREACHABLE_ERROR (nn))
@@ -11889,14 +11720,14 @@ java_complete_lhs (node)
       else
        {
          tree body;
-         int save_lineno = lineno;
-         lineno = EXPR_WFL_LINENO (node);
+         int save_lineno = input_line;
+         input_line = EXPR_WFL_LINENO (node);
          body = java_complete_tree (EXPR_WFL_NODE (node));
-         lineno = save_lineno;
+         input_line = save_lineno;
          EXPR_WFL_NODE (node) = body;
          TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
          CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
-         if (body == empty_stmt_node || TREE_CONSTANT (body))
+         if (IS_EMPTY_STMT (body) || TREE_CONSTANT (body))
            {
              /* Makes it easier to constant fold, detect empty bodies. */
              return body;
@@ -11972,13 +11803,20 @@ java_complete_lhs (node)
          int in_this = CALL_THIS_CONSTRUCTOR_P (node);
          int from_super = (EXPR_WFL_NODE (TREE_OPERAND (node, 0)) ==
                            super_identifier_node);
+         tree arguments;
+         int location = EXPR_WFL_LINECOL (node);
 
          node = patch_method_invocation (node, NULL_TREE, NULL_TREE,
                                          from_super, 0, &decl);
          if (node == error_mark_node)
            return error_mark_node;
 
-         check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
+         if (TREE_CODE (node) == CALL_EXPR
+             && TREE_OPERAND (node, 1) != NULL_TREE)
+           arguments = TREE_VALUE (TREE_OPERAND (node, 1));
+         else
+           arguments = NULL_TREE;
+         check_thrown_exceptions (location, decl, arguments);
          /* If we call this(...), register signature and positions */
          if (in_this)
            DECL_CONSTRUCTOR_CALLS (current_function_decl) =
@@ -12004,8 +11842,8 @@ java_complete_lhs (node)
          /* When we have a primitype type, or a string and we're not
              emitting a class file, we actually don't want to generate
              anything for the assignment. */
-         if (value != NULL_TREE &&
-             (JPRIMITIVE_TYPE_P (TREE_TYPE (value)) ||
+         if (value != NULL_TREE && 
+             (JPRIMITIVE_TYPE_P (TREE_TYPE (value)) || 
               (TREE_TYPE (value) == string_ptr_type_node &&
                ! flag_emit_class_files)))
            {
@@ -12025,7 +11863,7 @@ java_complete_lhs (node)
                  else
                    DECL_INITIAL (nn) = TREE_OPERAND (node, 1);
                  DECL_FIELD_FINAL_IUD (nn) = 1;
-                 return empty_stmt_node;
+                 return build_java_empty_stmt ();
                }
            }
          if (! flag_emit_class_files)
@@ -12173,7 +12011,7 @@ java_complete_lhs (node)
 
           TREE_OPERAND (node, 1) = nn;
         }
-      return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
+      return patch_binop (node, wfl_op1, wfl_op2);
 
     case INSTANCEOF_EXPR:
       wfl_op1 = TREE_OPERAND (node, 0);
@@ -12293,8 +12131,7 @@ java_complete_lhs (node)
    error was found.  */
 
 static int
-complete_function_arguments (node)
-     tree node;
+complete_function_arguments (tree node)
 {
   int flag = 0;
   tree cn;
@@ -12310,8 +12147,8 @@ complete_function_arguments (node)
          flag = 1;
          continue;
        }
-      /* If have a string literal that we haven't transformed yet or a
-        crafted string buffer, as a result of use of the the String
+      /* If we have a string literal that we haven't transformed yet or a
+        crafted string buffer, as a result of the use of the String
         `+' operator. Build `parm.toString()' and expand it. */
       if ((temp = patch_string (parm)))
        parm = temp;
@@ -12327,9 +12164,7 @@ complete_function_arguments (node)
    debugable.  */
 
 static tree
-build_debugable_stmt (location, stmt)
-    int location;
-    tree stmt;
+build_debugable_stmt (int location, tree stmt)
 {
   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
     {
@@ -12341,8 +12176,7 @@ build_debugable_stmt (location, stmt)
 }
 
 static tree
-build_expr_block (body, decls)
-     tree body, decls;
+build_expr_block (tree body, tree decls)
 {
   tree node = make_node (BLOCK);
   BLOCK_EXPR_DECLS (node) = decls;
@@ -12357,7 +12191,7 @@ build_expr_block (body, decls)
    function block chain */
 
 static tree
-enter_block ()
+enter_block (void)
 {
   tree b = build_expr_block (NULL_TREE, NULL_TREE);
 
@@ -12391,7 +12225,7 @@ enter_block ()
    the block being exited isn't the method's top level one.  */
 
 static tree
-exit_block ()
+exit_block (void)
 {
   tree b;
   if (current_function_decl)
@@ -12415,8 +12249,7 @@ exit_block ()
    scoping rules.  */
 
 static tree
-lookup_name_in_blocks (name)
-     tree name;
+lookup_name_in_blocks (tree name)
 {
   tree b = GET_CURRENT_BLOCK (current_function_decl);
 
@@ -12438,13 +12271,13 @@ lookup_name_in_blocks (name)
 }
 
 static void
-maybe_absorb_scoping_blocks ()
+maybe_absorb_scoping_blocks (void)
 {
   while (BLOCK_IS_IMPLICIT (GET_CURRENT_BLOCK (current_function_decl)))
     {
       tree b = exit_block ();
       java_method_add_stmt (current_function_decl, b);
-      SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
+      SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", input_line));
     }
 }
 
@@ -12456,13 +12289,11 @@ maybe_absorb_scoping_blocks ()
 /* Wrap a non WFL node around a WFL.  */
 
 static tree
-build_wfl_wrap (node, location)
-    tree node;
-    int location;
+build_wfl_wrap (tree node, int location)
 {
   tree wfl, node_to_insert = node;
 
-  /* We want to process THIS . xxx symbolicaly, to keep it consistent
+  /* We want to process THIS . xxx symbolically, to keep it consistent
      with the way we're processing SUPER. A THIS from a primary as a
      different form than a SUPER. Turn THIS into something symbolic */
   if (TREE_CODE (node) == THIS_EXPR)
@@ -12475,19 +12306,24 @@ build_wfl_wrap (node, location)
   return wfl;
 }
 
-/* Build a super() constructor invocation. Returns empty_stmt_node if
+/* Build a super() constructor invocation. Returns an empty statement if
    we're currently dealing with the class java.lang.Object. */
 
 static tree
-build_super_invocation (mdecl)
-     tree mdecl;
+build_super_invocation (tree mdecl)
 {
   if (DECL_CONTEXT (mdecl) == object_type_node)
-    return empty_stmt_node;
+    return build_java_empty_stmt ();
   else
     {
       tree super_wfl = build_wfl_node (super_identifier_node);
       tree a = NULL_TREE, t;
+
+      /* This is called after parsing is done, so the parser context
+         won't be accurate. Set location info from current_class decl. */
+      tree class_wfl = lookup_cl (TYPE_NAME (current_class));
+      EXPR_WFL_LINECOL (super_wfl) = EXPR_WFL_LINECOL (class_wfl);
+
       /* If we're dealing with an anonymous class, pass the arguments
          of the crafted constructor along. */
       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
@@ -12503,10 +12339,8 @@ build_super_invocation (mdecl)
 /* Build a SUPER/THIS qualified method invocation.  */
 
 static tree
-build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
-     int use_this;
-     tree name, args;
-     int lloc, rloc;
+build_this_super_qualified_invocation (int use_this, tree name, tree args,
+                                      int lloc, int rloc)
 {
   tree invok;
   tree wfl =
@@ -12519,9 +12353,7 @@ build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
 /* Build an incomplete CALL_EXPR node. */
 
 static tree
-build_method_invocation (name, args)
-    tree name;
-    tree args;
+build_method_invocation (tree name, tree args)
 {
   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
   TREE_SIDE_EFFECTS (call) = 1;
@@ -12532,8 +12364,7 @@ build_method_invocation (name, args)
 /* Build an incomplete new xxx(...) node. */
 
 static tree
-build_new_invocation (name, args)
-    tree name, args;
+build_new_invocation (tree name, tree args)
 {
   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
   TREE_SIDE_EFFECTS (call) = 1;
@@ -12544,9 +12375,7 @@ build_new_invocation (name, args)
 /* Build an incomplete assignment expression. */
 
 static tree
-build_assignment (op, op_location, lhs, rhs)
-     int op, op_location;
-     tree lhs, rhs;
+build_assignment (int op, int op_location, tree lhs, tree rhs)
 {
   tree assignment;
   /* Build the corresponding binop if we deal with a Compound
@@ -12566,20 +12395,20 @@ build_assignment (op, op_location, lhs, rhs)
 /* Print an INTEGER_CST node as decimal in a static buffer, and return
    the buffer.  This is used only for string conversion.  */
 static char *
-string_convert_int_cst (node)
-     tree node;
+string_convert_int_cst (tree node)
 {
-  static char buffer[80];
+  /* Long.MIN_VALUE is -9223372036854775808, 20 characters.  */
+  static char buffer[21];
 
   unsigned HOST_WIDE_INT lo = TREE_INT_CST_LOW (node);
   unsigned HOST_WIDE_INT hi = TREE_INT_CST_HIGH (node);
-  char *p = buffer + sizeof (buffer) - 1;
+  char *p = buffer + sizeof (buffer);
   int neg = 0;
 
   unsigned HOST_WIDE_INT hibit = (((unsigned HOST_WIDE_INT) 1)
                                  << (HOST_BITS_PER_WIDE_INT - 1));
 
-  *p-- = '\0';
+  *--p = '\0';
 
   /* If negative, note the fact and negate the value.  */
   if ((hi & hibit))
@@ -12592,7 +12421,7 @@ string_convert_int_cst (node)
     }
 
   /* Divide by 10 until there are no bits left.  */
-  while (hi || lo)
+  do
     {
       unsigned HOST_WIDE_INT acc = 0;
       unsigned HOST_WIDE_INT outhi = 0, outlo = 0;
@@ -12624,24 +12453,24 @@ string_convert_int_cst (node)
            }
        }
 
-      /* FIXME: ASCII assumption.  */
-      *p-- = '0' + acc;
+      /* '0' == 060 in Java, but might not be here (think EBCDIC).  */
+      *--p = '\060' + acc;
 
       hi = outhi;
       lo = outlo;
     }
+  while (hi || lo);
 
   if (neg)
-    *p-- = '-';
+    *--p = '\055'; /* '-' == 055 in Java, but might not be here.  */
 
-  return p + 1;
+  return p;
 }
 
 /* Print an INTEGER_CST node in a static buffer, and return the
    buffer.  This is used only for error handling.  */
 char *
-print_int_node (node)
-    tree node;
+print_int_node (tree node)
 {
   static char buffer [80];
   if (TREE_CONSTANT_OVERFLOW (node))
@@ -12652,11 +12481,8 @@ print_int_node (node)
             TREE_INT_CST_LOW (node));
   else if (TREE_INT_CST_HIGH (node) == -1
           && TREE_INT_CST_LOW (node) != 0)
-    {
-      buffer [0] = '-';
-      sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
-              -TREE_INT_CST_LOW (node));
-    }
+    sprintf (buffer, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
+            -TREE_INT_CST_LOW (node));
   else
     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
             TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
@@ -12671,9 +12497,7 @@ print_int_node (node)
 /* 15.25 Assignment operators. */
 
 static tree
-patch_assignment (node, wfl_op1)
-     tree node;
-     tree wfl_op1;
+patch_assignment (tree node, tree wfl_op1)
 {
   tree rhs = TREE_OPERAND (node, 1);
   tree lvalue = TREE_OPERAND (node, 0), llvalue;
@@ -12728,8 +12552,8 @@ patch_assignment (node, wfl_op1)
   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
 
   /* 5.2 If it failed, try a reference conversion */
-  if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
-    lhs_type = promote_type (rhs_type);
+  if (!new_rhs)
+    new_rhs = try_reference_assignconv (lhs_type, rhs);
 
   /* 15.25.2 If we have a compound assignment, convert RHS into the
      type of the LHS */
@@ -12830,9 +12654,48 @@ patch_assignment (node, wfl_op1)
       )
     {
       TREE_CONSTANT (lvalue) = 1;
+      TREE_INVARIANT (lvalue) = 1;
       DECL_INITIAL (lvalue) = new_rhs;
     }
 
+  /* Copy the rhs if it's a reference.  */
+  if (! flag_check_references && ! flag_emit_class_files && optimize > 0)
+    {
+      switch (TREE_CODE (new_rhs))
+       {
+       case ARRAY_REF:
+       case INDIRECT_REF:
+       case COMPONENT_REF:
+         /* Transform a = foo.bar 
+            into a = ({int tmp; tmp = foo.bar;}).
+            We need to ensure that if a read from memory fails
+            because of a NullPointerException, a destination variable
+            will remain unchanged.  An explicit temporary does what
+            we need.  
+
+            If flag_check_references is set, this is unnecessary
+            because we'll check each reference before doing any
+            reads.  If optimize is not set the result will never be
+            written to a stack slot that contains the LHS.  */
+         {
+           tree tmp = build_decl (VAR_DECL, get_identifier ("<tmp>"), 
+                                  TREE_TYPE (new_rhs));
+           tree block = make_node (BLOCK);
+           tree assignment 
+             = build (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
+           DECL_CONTEXT (tmp) = current_function_decl;
+           TREE_TYPE (block) = TREE_TYPE (new_rhs);
+           BLOCK_VARS (block) = tmp;
+           BLOCK_EXPR_BODY (block) = assignment;
+           TREE_SIDE_EFFECTS (block) = 1;
+           new_rhs = block;
+         }
+         break;
+       default:
+         break;
+       }
+    }
+
   TREE_OPERAND (node, 0) = lvalue;
   TREE_OPERAND (node, 1) = new_rhs;
   TREE_TYPE (node) = lhs_type;
@@ -12844,8 +12707,7 @@ patch_assignment (node, wfl_op1)
    modified rhs.  */
 
 static tree
-try_reference_assignconv (lhs_type, rhs)
-     tree lhs_type, rhs;
+try_reference_assignconv (tree lhs_type, tree rhs)
 {
   tree new_rhs = NULL_TREE;
   tree rhs_type = TREE_TYPE (rhs);
@@ -12871,8 +12733,7 @@ try_reference_assignconv (lhs_type, rhs)
    builtin type. Return a converted RHS if the conversion is possible.  */
 
 static tree
-try_builtin_assignconv (wfl_op1, lhs_type, rhs)
-     tree wfl_op1, lhs_type, rhs;
+try_builtin_assignconv (tree wfl_op1, tree lhs_type, tree rhs)
 {
   tree new_rhs = NULL_TREE;
   tree rhs_type = TREE_TYPE (rhs);
@@ -12919,11 +12780,10 @@ try_builtin_assignconv (wfl_op1, lhs_type, rhs)
 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
    conversion (5.1.1) or widening primitive conversion (5.1.2).  Return
    0 is the conversion test fails.  This implements parts the method
-   invocation convertion (5.3).  */
+   invocation conversion (5.3).  */
 
 static int
-valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
-     tree lhs_type, rhs_type;
+valid_builtin_assignconv_identity_widening_p (tree lhs_type, tree rhs_type)
 {
   /* 5.1.1: This is the identity conversion part. */
   if (lhs_type == rhs_type)
@@ -12968,10 +12828,7 @@ valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
    assignment check. */
 
 static int
-valid_ref_assignconv_cast_p (source, dest, cast)
-     tree source;
-     tree dest;
-     int cast;
+valid_ref_assignconv_cast_p (tree source, tree dest, int cast)
 {
   /* SOURCE or DEST might be null if not from a declared entity. */
   if (!source || !dest)
@@ -13013,7 +12870,7 @@ valid_ref_assignconv_cast_p (source, dest, cast)
          /* Otherwise, SOURCE must implement DEST */
          return interface_of_p (dest, source);
        }
-      /* DEST is an array, cast permited if SOURCE is of Object type */
+      /* DEST is an array, cast permitted if SOURCE is of Object type */
       return (cast && source == object_type_node ? 1 : 0);
     }
   if (TYPE_INTERFACE_P (source))
@@ -13101,9 +12958,7 @@ valid_ref_assignconv_cast_p (source, dest, cast)
 }
 
 static int
-valid_cast_to_p (source, dest)
-     tree source;
-     tree dest;
+valid_cast_to_p (tree source, tree dest)
 {
   if (TREE_CODE (source) == POINTER_TYPE)
     source = TREE_TYPE (source);
@@ -13124,8 +12979,7 @@ valid_cast_to_p (source, dest)
 }
 
 static tree
-do_unary_numeric_promotion (arg)
-     tree arg;
+do_unary_numeric_promotion (tree arg)
 {
   tree type = TREE_TYPE (arg);
   if ((TREE_CODE (type) == INTEGER_TYPE && TYPE_PRECISION (type) < 32)
@@ -13137,8 +12991,7 @@ do_unary_numeric_promotion (arg)
 /* Return a nonzero value if SOURCE can be converted into DEST using
    the method invocation conversion rule (5.3).  */
 static int
-valid_method_invocation_conversion_p (dest, source)
-     tree dest, source;
+valid_method_invocation_conversion_p (tree dest, tree source)
 {
   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
           && valid_builtin_assignconv_identity_widening_p (dest, source))
@@ -13150,10 +13003,7 @@ valid_method_invocation_conversion_p (dest, source)
 /* Build an incomplete binop expression. */
 
 static tree
-build_binop (op, op_location, op1, op2)
-     enum tree_code op;
-     int op_location;
-     tree op1, op2;
+build_binop (enum tree_code op, int op_location, tree op1, tree op2)
 {
   tree binop = build (op, NULL_TREE, op1, op2);
   TREE_SIDE_EFFECTS (binop) = 1;
@@ -13170,8 +13020,7 @@ build_binop (op, op_location, op1, op2)
    buffer. */
 
 static char *
-operator_string (node)
-     tree node;
+operator_string (tree node)
 {
 #define BUILD_OPERATOR_STRING(S)                                       \
   {                                                                    \
@@ -13220,8 +13069,7 @@ operator_string (node)
 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
 
 static int
-java_decl_equiv (var_acc1, var_acc2)
-     tree var_acc1, var_acc2;
+java_decl_equiv (tree var_acc1, tree var_acc2)
 {
   if (JDECL_P (var_acc1))
     return (var_acc1 == var_acc2);
@@ -13237,8 +13085,7 @@ java_decl_equiv (var_acc1, var_acc2)
    used in conjunction with the `=' operator in a compound assignment.  */
 
 static int
-binop_compound_p (code)
-    enum tree_code code;
+binop_compound_p (enum tree_code code)
 {
   int i;
   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
@@ -13251,8 +13098,7 @@ binop_compound_p (code)
 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
 
 static tree
-java_refold (t)
-     tree t;
+java_refold (tree t)
 {
   tree c, b, ns, decl;
 
@@ -13299,10 +13145,7 @@ java_refold (t)
    of remaining nodes and detects more errors in certain cases.  */
 
 static tree
-patch_binop (node, wfl_op1, wfl_op2)
-     tree node;
-     tree wfl_op1;
-     tree wfl_op2;
+patch_binop (tree node, tree wfl_op1, tree wfl_op2)
 {
   tree op1 = TREE_OPERAND (node, 0);
   tree op2 = TREE_OPERAND (node, 1);
@@ -13365,13 +13208,14 @@ patch_binop (node, wfl_op1, wfl_op2)
        {
          parse_warning_context (wfl_operator, "Evaluating this expression will result in an arithmetic exception being thrown");
          TREE_CONSTANT (node) = 0;
+         TREE_INVARIANT (node) = 0;
        }
 
       /* Change the division operator if necessary */
       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
        TREE_SET_CODE (node, TRUNC_DIV_EXPR);
 
-      /* Before divisions as is disapear, try to simplify and bail if
+      /* Before divisions as is disappear, try to simplify and bail if
          applicable, otherwise we won't perform even simple
          simplifications like (1-1)/3. We can't do that with floating
          point number, folds can't handle them at this stage. */
@@ -13501,7 +13345,7 @@ patch_binop (node, wfl_op1, wfl_op2)
        }
       break;
 
-      /* 15.19.1 Type Comparison Operator instaceof */
+      /* 15.19.1 Type Comparison Operator instanceof */
     case INSTANCEOF_EXPR:
 
       TREE_TYPE (node) = boolean_type_node;
@@ -13722,10 +13566,7 @@ patch_binop (node, wfl_op1, wfl_op2)
    zero value, the value of CSTE comes after the valude of STRING */
 
 static tree
-do_merge_string_cste (cste, string, string_len, after)
-     tree cste;
-     const char *string;
-     int string_len, after;
+do_merge_string_cste (tree cste, const char *string, int string_len, int after)
 {
   const char *old = TREE_STRING_POINTER (cste);
   int old_len = TREE_STRING_LENGTH (cste);
@@ -13747,48 +13588,56 @@ do_merge_string_cste (cste, string, string_len, after)
 }
 
 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
-   new STRING_CST on success, NULL_TREE on failure */
+   new STRING_CST on success, NULL_TREE on failure */
 
 static tree
-merge_string_cste (op1, op2, after)
-     tree op1, op2;
-     int after;
+merge_string_cste (tree op1, tree op2, int after)
 {
-  /* Handle two string constants right away */
+  /* Handle two string constants right away */
   if (TREE_CODE (op2) == STRING_CST)
     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
                                 TREE_STRING_LENGTH (op2), after);
 
-  /* Reasonable integer constant can be treated right away */
+  /* Reasonable integer constant can be treated right away */
   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
     {
       static const char *const boolean_true = "true";
       static const char *const boolean_false = "false";
       static const char *const null_pointer = "null";
-      char ch[3];
+      char ch[4];
       const char *string;
 
       if (op2 == boolean_true_node)
        string = boolean_true;
       else if (op2 == boolean_false_node)
        string = boolean_false;
-      else if (op2 == null_pointer_node)
+      else if (op2 == null_pointer_node
+              || (integer_zerop (op2)
+                  && TREE_CODE (TREE_TYPE (op2)) == POINTER_TYPE))
+       /* FIXME: null is not a compile-time constant, so it is only safe to
+          merge if the overall expression is non-constant. However, this
+          code always merges without checking the overall expression.  */
        string = null_pointer;
       else if (TREE_TYPE (op2) == char_type_node)
        {
          /* Convert the character into UTF-8.  */
-         unsigned char c = (unsigned char) TREE_INT_CST_LOW (op2);
+         unsigned int c = (unsigned int) TREE_INT_CST_LOW (op2);
          unsigned char *p = (unsigned char *) ch;
-         if (0x01 <= c
-             && c <= 0x7f)
-           *p++ = c;
+         if (0x01 <= c && c <= 0x7f)
+           *p++ = (unsigned char) c;
+         else if (c < 0x7ff)
+           {
+             *p++ = (unsigned char) (c >> 6 | 0xc0);
+             *p++ = (unsigned char) ((c & 0x3f) | 0x80);
+           }
          else
            {
-             *p++ = c >> 6 | 0xc0;
-             *p++ = (c & 0x3f) | 0x80;
+             *p++ = (unsigned char) (c >> 12 | 0xe0);
+             *p++ = (unsigned char) (((c >> 6) & 0x3f) | 0x80);
+             *p++ = (unsigned char) ((c & 0x3f) | 0x80);
            }
          *p = '\0';
+
          string = ch;
        }
       else
@@ -13808,8 +13657,7 @@ merge_string_cste (op1, op2, after)
    NULL_TREE for each invocation of this routine. FIXME */
 
 static tree
-string_constant_concatenation (op1, op2)
-     tree op1, op2;
+string_constant_concatenation (tree op1, tree op2)
 {
   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
     {
@@ -13843,8 +13691,7 @@ string_constant_concatenation (op1, op2)
    called on it to turn it into a String object. */
 
 static tree
-build_string_concatenation (op1, op2)
-     tree op1, op2;
+build_string_concatenation (tree op1, tree op2)
 {
   tree result;
   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
@@ -13913,8 +13760,7 @@ build_string_concatenation (op1, op2)
    NULL. */
 
 static tree
-patch_string (node)
-    tree node;
+patch_string (tree node)
 {
   if (node == error_mark_node)
     return error_mark_node;
@@ -13940,8 +13786,7 @@ patch_string (node)
 /* Build the internal representation of a string constant.  */
 
 static tree
-patch_string_cst (node)
-     tree node;
+patch_string_cst (tree node)
 {
   int location;
   if (! flag_emit_class_files)
@@ -13950,17 +13795,22 @@ patch_string_cst (node)
       location = alloc_name_constant (CONSTANT_String, node);
       node = build_ref_from_constant_pool (location);
     }
-  TREE_TYPE (node) = string_ptr_type_node;
   TREE_CONSTANT (node) = 1;
+  TREE_INVARIANT (node) = 1;
+
+  /* ??? Guessing that the class file code can't handle casts.  */
+  if (! flag_emit_class_files)
+    node = convert (string_ptr_type_node, node);
+  else
+    TREE_TYPE (node) = string_ptr_type_node;
+
   return node;
 }
 
 /* Build an incomplete unary operator expression. */
 
 static tree
-build_unaryop (op_token, op_location, op1)
-     int op_token, op_location;
-     tree op1;
+build_unaryop (int op_token, int op_location, tree op1)
 {
   enum tree_code op;
   tree unaryop;
@@ -13986,10 +13836,7 @@ build_unaryop (op_token, op_location, op1)
    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
 
 static tree
-build_incdec (op_token, op_location, op1, is_post_p)
-     int op_token, op_location;
-     tree op1;
-     int is_post_p;
+build_incdec (int op_token, int op_location, tree op1, int is_post_p)
 {
   static const enum tree_code lookup [2][2] =
     {
@@ -14011,9 +13858,7 @@ build_incdec (op_token, op_location, op1, is_post_p)
    though its type is already set.  */
 
 static tree
-build_cast (location, type, exp)
-     int location;
-     tree type, exp;
+build_cast (int location, tree type, tree exp)
 {
   tree node = build1 (CONVERT_EXPR, type, exp);
   EXPR_WFL_LINECOL (node) = location;
@@ -14022,19 +13867,61 @@ build_cast (location, type, exp)
 
 /* Build an incomplete class reference operator.  */
 static tree
-build_incomplete_class_ref (location, class_name)
-    int location;
-    tree class_name;
+build_incomplete_class_ref (int location, tree class_name)
 {
   tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
+  tree class_decl = GET_CPC ();
+  tree this_class = TREE_TYPE (class_decl);
+
+  /* Generate the synthetic static method `class$'.  (Previously we
+     deferred this, causing different method tables to be emitted
+     for native code and bytecode.)  */
+  if (!TYPE_DOT_CLASS (this_class)
+      && !JPRIMITIVE_TYPE_P (class_name)
+      && !(TREE_CODE (class_name) == VOID_TYPE))
+    {
+      tree cpc_list = GET_CPC_LIST();
+      tree cpc = cpc_list;
+      tree target_class;
+
+      /* For inner classes, add a 'class$' method to their outermost
+        context, creating it if necessary.  */
+      
+      while (GET_NEXT_ENCLOSING_CPC(cpc))
+       cpc = GET_NEXT_ENCLOSING_CPC(cpc);
+      class_decl = TREE_VALUE (cpc);
+
+      target_class = TREE_TYPE (class_decl);
+
+      if (CLASS_INTERFACE (TYPE_NAME (target_class)))
+       {
+         /* For interfaces, adding a static 'class$' method directly 
+            is illegal.  So create an inner class to contain the new
+            method.  Empirically this matches the behavior of javac.  */
+         tree t, inner;
+         /* We want the generated inner class inside the outermost class. */
+         GET_CPC_LIST() = cpc;
+         t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node)));
+         inner = create_anonymous_class (t);
+         target_class = TREE_TYPE (inner);
+         end_class_declaration (1);
+         GET_CPC_LIST() = cpc_list;
+       }
+
+      if (TYPE_DOT_CLASS (target_class) == NULL_TREE)
+       build_dot_class_method (target_class);
+
+      if (this_class != target_class)
+       TYPE_DOT_CLASS (this_class) = TYPE_DOT_CLASS (target_class);
+    }
+
   EXPR_WFL_LINECOL (node) = location;
   return node;
 }
 
 /* Complete an incomplete class reference operator.  */
 static tree
-patch_incomplete_class_ref (node)
-    tree node;
+patch_incomplete_class_ref (tree node)
 {
   tree type = TREE_OPERAND (node, 0);
   tree ref_type;
@@ -14042,12 +13929,6 @@ patch_incomplete_class_ref (node)
   if (!(ref_type = resolve_type_during_patch (type)))
     return error_mark_node;
 
-  /* Generate the synthetic static method `class$'.  (Previously we
-     deferred this, causing different method tables to be emitted
-     for native code and bytecode.)  */
-  if (!TYPE_DOT_CLASS (current_class))
-      build_dot_class_method (current_class);
-
   /* If we're not emitting class files and we know ref_type is a
      compiled class, build a direct reference.  */
   if ((! flag_emit_class_files && is_compiled_class (ref_type))
@@ -14063,7 +13944,7 @@ patch_incomplete_class_ref (node)
 
   /* If we're emitting class files and we have to deal with non
      primitive types, we invoke the synthetic static method `class$'.  */
-  ref_type = build_dot_class_method_invocation (ref_type);
+  ref_type = build_dot_class_method_invocation (current_class, ref_type);
   return java_complete_tree (ref_type);
 }
 
@@ -14071,9 +13952,7 @@ patch_incomplete_class_ref (node)
    but preserve the type of NODE if the type is fixed.  */
 
 static tree
-patch_unaryop (node, wfl_op)
-     tree node;
-     tree wfl_op;
+patch_unaryop (tree node, tree wfl_op)
 {
   tree op = TREE_OPERAND (node, 0);
   tree op_type = TREE_TYPE (op);
@@ -14261,8 +14140,7 @@ patch_unaryop (node, wfl_op)
    message. Return the resolved type or NULL_TREE.  */
 
 static tree
-resolve_type_during_patch (type)
-     tree type;
+resolve_type_during_patch (tree type)
 {
   if (unresolved_type_p (type, NULL))
     {
@@ -14274,17 +14152,19 @@ resolve_type_during_patch (type)
                               IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
          return NULL_TREE;
        }
+
+      check_deprecation (type, type_decl);
+
       return TREE_TYPE (type_decl);
     }
   return type;
 }
+
 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
    found. Otherwise NODE or something meant to replace it is returned.  */
 
 static tree
-patch_cast (node, wfl_op)
-     tree node;
-     tree wfl_op;
+patch_cast (tree node, tree wfl_op)
 {
   tree op = TREE_OPERAND (node, 0);
   tree cast_type = TREE_TYPE (node);
@@ -14307,14 +14187,15 @@ patch_cast (node, wfl_op)
       if (cast_type == op_type)
        return node;
 
-      /* float and double type are converted to the original type main
-        variant and then to the target type. */
-      if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
-       op = convert (integer_type_node, op);
+      /* A narrowing conversion from a floating-point number to an
+        integral type requires special handling (5.1.3).  */
+      if (JFLOAT_TYPE_P (op_type) && JINTEGRAL_TYPE_P (cast_type))
+       if (cast_type != long_type_node)
+         op = convert (integer_type_node, op);
 
-      /* Try widening/narowwing convertion. Potentially, things need
+      /* Try widening/narrowing conversion.  Potentially, things need
         to be worked out in gcc so we implement the extreme cases
-        correctly. fold_convert() needs to be fixed. */
+        correctly.  fold_convert() needs to be fixed.  */
       return convert (cast_type, op);
     }
 
@@ -14367,8 +14248,7 @@ patch_cast (node, wfl_op)
 /* Build a null constant and give it the type TYPE.  */
 
 static tree
-build_null_of_type (type)
-     tree type;
+build_null_of_type (tree type)
 {
   tree node = build_int_2 (0, 0);
   TREE_TYPE (node) = promote_type (type);
@@ -14378,11 +14258,9 @@ build_null_of_type (type)
 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
    a list of indices. */
 static tree
-build_array_ref (location, array, index)
-     int location;
-     tree array, index;
+build_array_ref (int location, tree array, tree index)
 {
-  tree node = build (ARRAY_REF, NULL_TREE, array, index);
+  tree node = build (ARRAY_REF, NULL_TREE, array, index, NULL_TREE, NULL_TREE);
   EXPR_WFL_LINECOL (node) = location;
   return node;
 }
@@ -14390,8 +14268,7 @@ build_array_ref (location, array, index)
 /* 15.12 Array Access Expression */
 
 static tree
-patch_array_ref (node)
-     tree node;
+patch_array_ref (tree node)
 {
   tree array = TREE_OPERAND (node, 0);
   tree array_type  = TREE_TYPE (array);
@@ -14451,10 +14328,7 @@ patch_array_ref (node)
 /* 15.9 Array Creation Expressions */
 
 static tree
-build_newarray_node (type, dims, extra_dims)
-     tree type;
-     tree dims;
-     int extra_dims;
+build_newarray_node (tree type, tree dims, int extra_dims)
 {
   tree node =
     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
@@ -14463,8 +14337,7 @@ build_newarray_node (type, dims, extra_dims)
 }
 
 static tree
-patch_newarray (node)
-     tree node;
+patch_newarray (tree node)
 {
   tree type = TREE_OPERAND (node, 0);
   tree dims = TREE_OPERAND (node, 1);
@@ -14567,8 +14440,7 @@ patch_newarray (node)
    pin-point errors.  */
 
 static tree
-maybe_build_array_element_wfl (node)
-     tree node;
+maybe_build_array_element_wfl (tree node)
 {
   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
     return build_expr_wfl (NULL_TREE, ctxp->filename,
@@ -14582,11 +14454,9 @@ maybe_build_array_element_wfl (node)
    and expansion.  */
 
 static tree
-build_new_array_init (location, values)
-     int location;
-     tree values;
+build_new_array_init (int location, tree values)
 {
-  tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
+  tree constructor = build_constructor (NULL_TREE, values);
   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
   EXPR_WFL_LINECOL (to_return) = location;
   return to_return;
@@ -14597,8 +14467,7 @@ build_new_array_init (location, values)
    appropriately.  */
 
 static tree
-patch_new_array_init (type, node)
-     tree type, node;
+patch_new_array_init (tree type, tree node)
 {
   int error_seen = 0;
   tree current, element_type;
@@ -14652,7 +14521,9 @@ patch_new_array_init (type, node)
   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
   TREE_TYPE (node) = promote_type (type);
   TREE_CONSTANT (init) = all_constant;
+  TREE_INVARIANT (init) = all_constant;
   TREE_CONSTANT (node) = all_constant;
+  TREE_INVARIANT (node) = all_constant;
   return node;
 }
 
@@ -14661,8 +14532,7 @@ patch_new_array_init (type, node)
    otherwise.  */
 
 static int
-array_constructor_check_entry (type, entry)
-     tree type, entry;
+array_constructor_check_entry (tree type, tree entry)
 {
   char *array_type_string = NULL;      /* For error reports */
   tree value, type_value, new_value, wfl_value, patched;
@@ -14711,8 +14581,7 @@ array_constructor_check_entry (type, entry)
 }
 
 static tree
-build_this (location)
-     int location;
+build_this (int location)
 {
   tree node = build_wfl_node (this_identifier_node);
   TREE_SET_CODE (node, THIS_EXPR);
@@ -14725,9 +14594,7 @@ build_this (location)
    to be returned. */
 
 static tree
-build_return (location, op)
-     int location;
-     tree op;
+build_return (int location, tree op)
 {
   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
   EXPR_WFL_LINECOL (node) = location;
@@ -14736,8 +14603,7 @@ build_return (location, op)
 }
 
 static tree
-patch_return (node)
-     tree node;
+patch_return (tree node)
 {
   tree return_exp = TREE_OPERAND (node, 0);
   tree meth = current_function_decl;
@@ -14821,13 +14687,12 @@ patch_return (node)
 /* 14.8 The if Statement */
 
 static tree
-build_if_else_statement (location, expression, if_body, else_body)
-     int location;
-     tree expression, if_body, else_body;
+build_if_else_statement (int location, tree expression, tree if_body,
+                        tree else_body)
 {
   tree node;
   if (!else_body)
-    else_body = empty_stmt_node;
+    else_body = build_java_empty_stmt ();
   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
   EXPR_WFL_LINECOL (node) = location;
   node = build_debugable_stmt (location, node);
@@ -14835,8 +14700,7 @@ build_if_else_statement (location, expression, if_body, else_body)
 }
 
 static tree
-patch_if_else_statement (node)
-     tree node;
+patch_if_else_statement (tree node)
 {
   tree expression = TREE_OPERAND (node, 0);
   int can_complete_normally
@@ -14857,19 +14721,6 @@ patch_if_else_statement (node)
       return error_mark_node;
     }
 
-  if (TREE_CODE (expression) == INTEGER_CST)
-    {
-      if (integer_zerop (expression))
-       node = TREE_OPERAND (node, 2);
-      else
-       node = TREE_OPERAND (node, 1);
-      if (CAN_COMPLETE_NORMALLY (node) != can_complete_normally)
-       {
-         node = build (COMPOUND_EXPR, void_type_node, node, empty_stmt_node);
-         CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
-       }
-      return node;
-    }
   TREE_TYPE (node) = void_type_node;
   TREE_SIDE_EFFECTS (node) = 1;
   CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
@@ -14878,14 +14729,12 @@ patch_if_else_statement (node)
 
 /* 14.6 Labeled Statements */
 
-/* Action taken when a lableled statement is parsed. a new
+/* Action taken when a labeled statement is parsed. a new
    LABELED_BLOCK_EXPR is created. No statement is attached to the
    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
 
 static tree
-build_labeled_block (location, label)
-     int location;
-     tree label;
+build_labeled_block (int location, tree label)
 {
   tree label_name ;
   tree label_decl, node;
@@ -14921,9 +14770,8 @@ build_labeled_block (location, label)
 /* A labeled statement LBE is attached a statement.  */
 
 static tree
-finish_labeled_statement (lbe, statement)
-     tree lbe;                 /* Labeled block expr */
-     tree statement;
+finish_labeled_statement (tree lbe, /* Labeled block expr */
+                         tree statement)
 {
   /* In anyways, tie the loop to its statement */
   LABELED_BLOCK_BODY (lbe) = statement;
@@ -14938,8 +14786,7 @@ finish_labeled_statement (lbe, statement)
    list. */
 
 static tree
-build_new_loop (loop_body)
-     tree loop_body;
+build_new_loop (tree loop_body)
 {
   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
   TREE_SIDE_EFFECTS (loop) = 1;
@@ -14968,10 +14815,7 @@ build_new_loop (loop_body)
        <structure described above> */
 
 static tree
-build_loop_body (location, condition, reversed)
-     int location;
-     tree condition;
-     int reversed;
+build_loop_body (int location, tree condition, int reversed)
 {
   tree first, second, body;
 
@@ -14985,7 +14829,8 @@ build_loop_body (location, condition, reversed)
   second = (reversed ? condition : body);
   return
     build (COMPOUND_EXPR, NULL_TREE,
-          build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
+          build (COMPOUND_EXPR, NULL_TREE, first, second),
+                 build_java_empty_stmt ());
 }
 
 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
@@ -14993,10 +14838,7 @@ build_loop_body (location, condition, reversed)
    loop list.  */
 
 static tree
-finish_loop_body (location, condition, body, reversed)
-     int location;
-     tree condition, body;
-     int reversed;
+finish_loop_body (int location, tree condition, tree body, int reversed)
 {
   tree to_return = ctxp->current_loop;
   tree loop_body = LOOP_EXPR_BODY (to_return);
@@ -15019,9 +14861,7 @@ finish_loop_body (location, condition, body, reversed)
    loops feature the condition part */
 
 static tree
-finish_for_loop (location, condition, update, body)
-    int location;
-    tree condition, update, body;
+finish_for_loop (int location, tree condition, tree update, tree body)
 {
   /* Put the condition and the loop body in place */
   tree loop = finish_loop_body (location, condition, body, 0);
@@ -15030,17 +14870,22 @@ finish_for_loop (location, condition, update, body)
      this because the (current interpretation of the) JLS requires
      that the update expression be considered reachable even if the
      for loop's body doesn't complete normally.  */
-  if (update != NULL_TREE && update != empty_stmt_node)
+  if (update != NULL_TREE && !IS_EMPTY_STMT (update))
     {
       tree up2 = update;
       if (TREE_CODE (up2) == EXPR_WITH_FILE_LOCATION)
        up2 = EXPR_WFL_NODE (up2);
-      /* Try to detect constraint violations.  These would be
-        programming errors somewhere.  */
-      if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
-         || TREE_CODE (up2) == LOOP_EXPR)
-       abort ();
-      SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
+      /* It is possible for the update expression to be an
+        EXPR_WFL_NODE wrapping nothing.  */
+      if (up2 != NULL_TREE && !IS_EMPTY_STMT (up2))
+       {
+         /* Try to detect constraint violations.  These would be
+            programming errors somewhere.  */
+         if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
+             || TREE_CODE (up2) == LOOP_EXPR)
+           abort ();
+         SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
+       }
     }
   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
   return loop;
@@ -15055,8 +14900,7 @@ finish_for_loop (location, condition, update, body)
    LABELED_BLOCK_EXPR's block.  */
 
 static tree
-search_loop (statement)
-    tree statement;
+search_loop (tree statement)
 {
   if (TREE_CODE (statement) == LOOP_EXPR)
     return statement;
@@ -15078,8 +14922,7 @@ search_loop (statement)
    returned otherwise.  */
 
 static int
-labeled_block_contains_loop_p (block, loop)
-    tree block, loop;
+labeled_block_contains_loop_p (tree block, tree loop)
 {
   if (!block)
     return 0;
@@ -15097,8 +14940,7 @@ labeled_block_contains_loop_p (block, loop)
    insert LOOP as its body.  */
 
 static tree
-patch_loop_statement (loop)
-     tree loop;
+patch_loop_statement (tree loop)
 {
   tree loop_label;
 
@@ -15120,9 +14962,7 @@ patch_loop_statement (loop)
    unlabeled break/continue statement.  */
 
 static tree
-build_bc_statement (location, is_break, name)
-     int location, is_break;
-     tree name;
+build_bc_statement (int location, int is_break, tree name)
 {
   tree break_continue, label_block_expr = NULL_TREE;
 
@@ -15132,7 +14972,7 @@ build_bc_statement (location, is_break, name)
            (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
        /* Null means that we don't have a target for this named
           break/continue. In this case, we make the target to be the
-          label name, so that the error can be reported accuratly in
+          label name, so that the error can be reported accurately in
           patch_bc_statement. */
        label_block_expr = EXPR_WFL_NODE (name);
     }
@@ -15151,8 +14991,7 @@ build_bc_statement (location, is_break, name)
 /* Verification of a break/continue statement. */
 
 static tree
-patch_bc_statement (node)
-     tree node;
+patch_bc_statement (tree node)
 {
   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
   tree labeled_block = ctxp->current_labeled_block;
@@ -15228,8 +15067,7 @@ patch_bc_statement (node)
    boolean.  */
 
 static tree
-patch_exit_expr (node)
-     tree node;
+patch_exit_expr (tree node)
 {
   tree expression = TREE_OPERAND (node, 0);
   TREE_TYPE (node) = error_mark_node;
@@ -15264,8 +15102,7 @@ patch_exit_expr (node)
 /* 14.9 Switch statement */
 
 static tree
-patch_switch_statement (node)
-     tree node;
+patch_switch_statement (tree node)
 {
   tree se = TREE_OPERAND (node, 0), se_type;
   tree save, iter;
@@ -15342,13 +15179,21 @@ patch_switch_statement (node)
 /* Build an assertion expression for `assert CONDITION : VALUE'; VALUE
    might be NULL_TREE.  */
 static tree
-build_assertion (location, condition, value)
-     int location;
-     tree condition, value;
+build_assertion (int location, tree condition, tree value)
 {
   tree node;
   tree klass = GET_CPC ();
 
+  if (! enable_assertions (klass))
+    {
+      condition = build (TRUTH_ANDIF_EXPR, NULL_TREE,
+                        boolean_false_node, condition);
+      if (value == NULL_TREE)
+       value = build_java_empty_stmt ();
+      return build_if_else_statement (location, condition,
+                                     value, NULL_TREE);
+    }
+
   if (! CLASS_USES_ASSERTIONS (klass))
     {
       tree field, classdollar, id, call;
@@ -15361,9 +15206,7 @@ build_assertion (location, condition, value)
       MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field);
       FIELD_SYNTHETIC (field) = 1;
 
-      if (!TYPE_DOT_CLASS (class_type))
-       build_dot_class_method (class_type);
-      classdollar = build_dot_class_method_invocation (class_type);
+      classdollar = build_incomplete_class_ref (location, class_type);
 
       /* Call CLASS.desiredAssertionStatus().  */
       id = build_wfl_node (get_identifier ("desiredAssertionStatus"));
@@ -15421,9 +15264,8 @@ build_assertion (location, condition, value)
    catches TYPE and executes CATCH_STMTS.  */
 
 static tree
-encapsulate_with_try_catch (location, type, try_stmts, catch_stmts)
-     int location;
-     tree type, try_stmts, catch_stmts;
+encapsulate_with_try_catch (int location, tree type_or_name, tree try_stmts,
+                           tree catch_stmts)
 {
   tree try_block, catch_clause_param, catch_block, catch;
 
@@ -15431,8 +15273,20 @@ encapsulate_with_try_catch (location, type, try_stmts, catch_stmts)
   try_block = build_expr_block (try_stmts, NULL_TREE);
 
   /* Build a catch block: we need a catch clause parameter */
-  catch_clause_param = build_decl (VAR_DECL,
-                                  wpv_id, build_pointer_type (type));
+  if (TREE_CODE (type_or_name) == EXPR_WITH_FILE_LOCATION)
+    {
+      tree catch_type = obtain_incomplete_type (type_or_name);
+      jdep *dep;
+      catch_clause_param = build_decl (VAR_DECL, wpv_id, catch_type);
+      register_incomplete_type (JDEP_VARIABLE, type_or_name,
+                               catch_clause_param, catch_type);
+      dep = CLASSD_LAST (ctxp->classd_list);
+      JDEP_GET_PATCH (dep) = &TREE_TYPE (catch_clause_param);
+    }
+  else
+    catch_clause_param = build_decl (VAR_DECL, wpv_id,
+                                    build_pointer_type (type_or_name));
+
   /* And a block */
   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
 
@@ -15444,16 +15298,14 @@ encapsulate_with_try_catch (location, type, try_stmts, catch_stmts)
   /* Add the catch statements */
   add_stmt_to_block (catch_block, NULL_TREE, catch_stmts);
 
-  /* Now we can build a CATCH_EXPR */
-  catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
+  /* Now we can build a JAVA_CATCH_EXPR */
+  catch_block = build1 (JAVA_CATCH_EXPR, NULL_TREE, catch_block);
 
   return build_try_statement (location, try_block, catch_block);
 }
 
 static tree
-build_try_statement (location, try_block, catches)
-     int location;
-     tree try_block, catches;
+build_try_statement (int location, tree try_block, tree catches)
 {
   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
   EXPR_WFL_LINECOL (node) = location;
@@ -15461,9 +15313,7 @@ build_try_statement (location, try_block, catches)
 }
 
 static tree
-build_try_finally_statement (location, try_block, finally)
-     int location;
-     tree try_block, finally;
+build_try_finally_statement (int location, tree try_block, tree finally)
 {
   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
   EXPR_WFL_LINECOL (node) = location;
@@ -15471,8 +15321,7 @@ build_try_finally_statement (location, try_block, finally)
 }
 
 static tree
-patch_try_statement (node)
-     tree node;
+patch_try_statement (tree node)
 {
   int error_found = 0;
   tree try = TREE_OPERAND (node, 0);
@@ -15491,7 +15340,7 @@ patch_try_statement (node)
       int unreachable;
 
       /* At this point, the structure of the catch clause is
-          CATCH_EXPR           (catch node)
+          JAVA_CATCH_EXPR              (catch node)
             BLOCK              (with the decl of the parameter)
                COMPOUND_EXPR
                  MODIFY_EXPR   (assignment of the catch parameter)
@@ -15583,8 +15432,7 @@ patch_try_statement (node)
 /* 14.17 The synchronized Statement */
 
 static tree
-patch_synchronized_statement (node, wfl_op1)
-    tree node, wfl_op1;
+patch_synchronized_statement (tree node, tree wfl_op1)
 {
   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
   tree block = TREE_OPERAND (node, 1);
@@ -15653,8 +15501,7 @@ patch_synchronized_statement (node, wfl_op1)
 /* 14.16 The throw Statement */
 
 static tree
-patch_throw_statement (node, wfl_op1)
-    tree node, wfl_op1;
+patch_throw_statement (tree node, tree wfl_op1)
 {
   tree expr = TREE_OPERAND (node, 0);
   tree type = TREE_TYPE (expr);
@@ -15753,24 +15600,32 @@ patch_throw_statement (node, wfl_op1)
 }
 
 /* Check that exception said to be thrown by method DECL can be
-   effectively caught from where DECL is invoked.  */
-
+   effectively caught from where DECL is invoked.  THIS_EXPR is the
+   expression that computes `this' for the method call.  */
 static void
-check_thrown_exceptions (location, decl)
-     int location;
-     tree decl;
+check_thrown_exceptions (int location, tree decl, tree this_expr)
 {
   tree throws;
-  /* For all the unchecked exceptions thrown by DECL */
+  int is_array_call = 0;
+
+  /* Skip check within generated methods, such as access$<n>.  */
+  if (OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (current_function_decl)))
+    return;
+
+  if (this_expr != NULL_TREE
+      && TREE_CODE (TREE_TYPE (this_expr)) == POINTER_TYPE
+      && TYPE_ARRAY_P (TREE_TYPE (TREE_TYPE (this_expr))))
+    is_array_call = 1;
+
+  /* For all the unchecked exceptions thrown by DECL.  */
   for (throws = DECL_FUNCTION_THROWS (decl); throws;
        throws = TREE_CHAIN (throws))
     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
       {
-#if 1
-       /* Temporary hack to suppresses errors about cloning arrays. FIXME */
-       if (DECL_NAME (decl) == get_identifier ("clone"))
+       /* Suppress errors about cloning arrays.  */
+       if (is_array_call && DECL_NAME (decl) == get_identifier ("clone"))
          continue;
-#endif
+
        EXPR_WFL_LINECOL (wfl_operator) = location;
        if (DECL_FINIT_P (current_function_decl))
          parse_error_context
@@ -15793,8 +15648,7 @@ check_thrown_exceptions (location, decl)
    current method.  */
 
 static int
-check_thrown_exceptions_do (exception)
-     tree exception;
+check_thrown_exceptions_do (tree exception)
 {
   tree list = currently_caught_type_list;
   resolve_and_layout (exception, NULL_TREE);
@@ -15814,8 +15668,7 @@ check_thrown_exceptions_do (exception)
 }
 
 static void
-purge_unchecked_exceptions (mdecl)
-     tree mdecl;
+purge_unchecked_exceptions (tree mdecl)
 {
   tree throws = DECL_FUNCTION_THROWS (mdecl);
   tree new = NULL_TREE;
@@ -15840,8 +15693,7 @@ purge_unchecked_exceptions (mdecl)
    otherwise.  */
 
 static bool
-ctors_unchecked_throws_clause_p (class_type)
-     tree class_type;
+ctors_unchecked_throws_clause_p (tree class_type)
 {
   tree current;
 
@@ -15869,8 +15721,7 @@ ctors_unchecked_throws_clause_p (class_type)
 /* 15.24 Conditional Operator ?: */
 
 static tree
-patch_conditional_expr (node, wfl_cond, wfl_op1)
-     tree node, wfl_cond, wfl_op1;
+patch_conditional_expr (tree node, tree wfl_cond, tree wfl_op1)
 {
   tree cond = TREE_OPERAND (node, 0);
   tree op1 = TREE_OPERAND (node, 1);
@@ -15983,8 +15834,7 @@ patch_conditional_expr (node, wfl_cond, wfl_op1)
 /* Wrap EXPR with code to initialize DECL's class, if appropriate. */
 
 static tree
-maybe_build_class_init_for_field (decl, expr)
-    tree decl, expr;
+maybe_build_class_init_for_field (tree decl, tree expr)
 {
   tree clas = DECL_CONTEXT (decl);
   if (flag_emit_class_files || flag_emit_xref)
@@ -16008,9 +15858,7 @@ maybe_build_class_init_for_field (decl, expr)
    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
 
 static tree
-fold_constant_for_init (node, context)
-     tree node;
-     tree context;
+fold_constant_for_init (tree node, tree context)
 {
   tree op0, op1, val;
   enum tree_code code = TREE_CODE (node);
@@ -16065,7 +15913,11 @@ fold_constant_for_init (node, context)
       if (val == NULL_TREE || ! TREE_CONSTANT (val))
        return NULL_TREE;
       TREE_OPERAND (node, 0) = val;
-      return patch_unaryop (node, op0);
+      val = patch_unaryop (node, op0);
+      if (! TREE_CONSTANT (val))
+       return NULL_TREE;
+      return val;
+
       break;
 
     case COND_EXPR:
@@ -16157,22 +16009,18 @@ fold_constant_for_init (node, context)
    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
 
 tree
-resolve_simple_name (name, context)
-     tree name;
-     int context;
+resolve_simple_name (tree name, int context)
 {
 }
 
 tree
-resolve_qualified_name (name, context)
-     tree name;
-     int context;
+resolve_qualified_name (tree name, int context)
 {
 }
 #endif
 
 void
-init_src_parse ()
+init_src_parse (void)
 {
   /* Sanity check; we've been bit by this before.  */
   if (ARRAY_SIZE (ctxp->modifier_ctx) != MODIFIER_TK - PUBLIC_TK)
@@ -16187,9 +16035,7 @@ init_src_parse ()
 /* Attach to PTR (a block) the declaration found in ENTRY. */
 
 static int
-attach_init_test_initialization_flags (entry, ptr)
-     void **entry;
-     void *ptr;
+attach_init_test_initialization_flags (void **entry, void *ptr)
 {
   tree block = (tree)ptr;
   struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
@@ -16202,16 +16048,14 @@ attach_init_test_initialization_flags (entry, ptr)
   return true;
 }
 
-/* This function is called for each classes that is known definitely
-   assigned when a given static method was called. This function
+/* This function is called for each class that is known definitely
+   initialized when a given static method was called. This function
    augments a compound expression (INFO) storing all assignment to
    initialized static class flags if a flag already existed, otherwise
    a new one is created.  */
 
 static int
-emit_test_initialization (entry_p, info)
-     void **entry_p;
-     void *info;
+emit_test_initialization (void **entry_p, void *info)
 {
   tree l = (tree) info;
   tree decl, init;
@@ -16239,6 +16083,8 @@ emit_test_initialization (entry_p, info)
       LOCAL_CLASS_INITIALIZATION_FLAG (decl) = 1;
       DECL_CONTEXT (decl) = current_function_decl;
       DECL_INITIAL (decl) = boolean_true_node;
+      /* Don't emit any symbolic debugging info for this decl.  */
+      DECL_IGNORED_P (decl) = 1;
 
       /* The trick is to find the right context for it. */
       block = BLOCK_SUBBLOCKS (GET_CURRENT_BLOCK (current_function_decl));