OSDN Git Service

* class.c (pushclass): Remove #if 0'd code.
[pf3gnuchains/gcc-fork.git] / gcc / cp / decl.c
index b363266..a07f6a9 100644 (file)
@@ -42,29 +42,15 @@ Boston, MA 02111-1307, USA.  */
 #include "except.h"
 #include "toplev.h"
 #include "../hash.h"
-#include "defaults.h"
 #include "ggc.h"
+#include "tm_p.h"
 
 extern int current_class_depth;
 
-extern tree static_ctors, static_dtors;
-
 extern tree global_namespace;
 
 extern int (*valid_lang_attribute) PARAMS ((tree, tree, tree, tree));
 
-/* Use garbage collection.  */
-
-int ggc_p = 1;
-
-#ifndef WCHAR_UNSIGNED
-#define WCHAR_UNSIGNED 0
-#endif
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
 #ifndef BOOL_TYPE_SIZE
 #ifdef SLOW_BYTE_ACCESS
 /* In the new ABI, `bool' has size and alignment `1', on all
@@ -94,7 +80,7 @@ int ggc_p = 1;
 #define WCHAR_TYPE "int"
 #endif
 
-static tree grokparms                          PARAMS ((tree, int));
+static tree grokparms                          PARAMS ((tree));
 static const char *redeclaration_error_message PARAMS ((tree, tree));
 
 static void push_binding_level PARAMS ((struct binding_level *, int,
@@ -169,10 +155,9 @@ static void mark_binding_level PARAMS ((void *));
 static void mark_named_label_lists PARAMS ((void *, void *));
 static void mark_cp_function_context PARAMS ((struct function *));
 static void mark_saved_scope PARAMS ((void *));
-static void mark_lang_function PARAMS ((struct language_function *));
-static void mark_stmt_tree PARAMS ((struct stmt_tree *));
+static void mark_lang_function PARAMS ((struct cp_language_function *));
 static void save_function_data PARAMS ((tree));
-static void check_function_type PARAMS ((tree));
+static void check_function_type PARAMS ((tree, tree));
 static void destroy_local_var PARAMS ((tree));
 static void finish_constructor_body PARAMS ((void));
 static void finish_destructor_body PARAMS ((void));
@@ -183,10 +168,11 @@ static tree start_cleanup_fn PARAMS ((void));
 static void end_cleanup_fn PARAMS ((void));
 static tree cp_make_fname_decl PARAMS ((tree, const char *, int));
 static void initialize_predefined_identifiers PARAMS ((void));
-static tree check_special_function_return_type 
+static tree check_special_function_return_type
   PARAMS ((special_function_kind, tree, tree, tree));
 static tree push_cp_library_fn PARAMS ((enum tree_code, tree));
 static tree build_cp_library_fn PARAMS ((tree, enum tree_code, tree));
+static void store_parm_decls PARAMS ((tree));
 
 #if defined (DEBUG_CP_BINDING_LEVELS)
 static void indent PARAMS ((void));
@@ -200,7 +186,6 @@ tree error_mark_list;
 
    C++ extensions
        tree wchar_decl_node;
-       tree void_zero_node;
 
        tree vtable_entry_type;
        tree delta_type_node;
@@ -263,8 +248,10 @@ tree cp_global_trees[CPTI_MAX];
 
 static tree global_type_node;
 
-/* Namespace std.  */
-int in_std;
+/* If non-zero, this is the number of times we have entered the `std'
+   namespace when we are treating that namespace as an alias for the
+   global namespace.  */
+static int in_fake_std;
 
 /* Expect only namespace names now. */
 static int only_namespace_names;
@@ -350,15 +337,6 @@ int flag_noniso_default_format_attributes = 1;
 
 extern int flag_short_double;
 
-/* Nonzero means don't recognize any builtin functions.  */
-
-extern int flag_no_builtin;
-
-/* Nonzero means don't recognize the non-ANSI builtin functions.
-   -ansi sets this.  */
-
-extern int flag_no_nonansi_builtin;
-
 /* Nonzero if we want to conserve space in the .o files.  We do this
    by putting uninitialized data and runtime initialized data into
    .common instead of .data at the expense of not flagging multiple
@@ -456,10 +434,6 @@ struct binding_level
        that were entered and exited one level down.  */
     tree blocks;
 
-    /* The BLOCK node for this level, if one has been preallocated.
-       If 0, the BLOCK is allocated (if needed) when the level is popped.  */
-    tree this_block;
-
     /* The _TYPE node for this level, if parm_flag == 2.  */
     tree this_class;
 
@@ -497,7 +471,7 @@ struct binding_level
        replaced with a TEMPLATE_DECL.  */
     unsigned template_parms_p : 1;
 
-    /* Nonzero if this scope corresponds to the `<>' in a 
+    /* Nonzero if this scope corresponds to the `<>' in a
        `template <>' clause.  Whenever this flag is set,
        TEMPLATE_PARMS_P will be set as well.  */
     unsigned template_spec_p : 1;
@@ -572,7 +546,7 @@ push_binding_level (newlevel, tag_transparent, keep)
 {
   /* Add this level to the front of the chain (stack) of levels that
      are active.  */
-  bzero ((char*) newlevel, sizeof (struct binding_level));
+  memset ((char*) newlevel, 0, sizeof (struct binding_level));
   newlevel->level_chain = current_binding_level;
   current_binding_level = newlevel;
   newlevel->tag_transparent = tag_transparent;
@@ -1297,7 +1271,6 @@ poplevel (keep, reverse, functionbody)
   tree subblocks;
   tree block = NULL_TREE;
   tree decl;
-  int block_previously_created;
   int leaving_for_scope;
 
   if (cfun && !doing_semantic_analysis_p ())
@@ -1405,34 +1378,12 @@ poplevel (keep, reverse, functionbody)
      or if this level is a function body,
      create a BLOCK to record them for the life of this function.  */
   block = NULL_TREE;
-  block_previously_created = (current_binding_level->this_block != NULL_TREE);
-  if (block_previously_created)
-    block = current_binding_level->this_block;
-  else if (keep == 1 || functionbody)
+  if (keep == 1 || functionbody)
     block = make_node (BLOCK);
   if (block != NULL_TREE)
     {
-      if (block_previously_created)
-       {
-         if (decls || tags || subblocks)
-           {
-             if (BLOCK_VARS (block))
-               warning ("internal compiler error: debugging info corrupted");
-
-             BLOCK_VARS (block) = decls;
-
-             /* We can have previous subblocks and new subblocks when
-                doing fixup_gotos with complex cleanups.  We chain the new
-                subblocks onto the end of any pre-existing subblocks.  */
-             BLOCK_SUBBLOCKS (block) = chainon (BLOCK_SUBBLOCKS (block),
-                                                subblocks);
-           }
-       }
-      else
-       {
-         BLOCK_VARS (block) = decls;
-         BLOCK_SUBBLOCKS (block) = subblocks;
-       }
+      BLOCK_VARS (block) = decls;
+      BLOCK_SUBBLOCKS (block) = subblocks;
     }
 
   /* In each subblock, record that this is its superior.  */
@@ -1583,11 +1534,9 @@ poplevel (keep, reverse, functionbody)
   if (functionbody)
     DECL_INITIAL (current_function_decl) = block;
   else if (block)
-    {
-      if (!block_previously_created)
-        current_binding_level->blocks
-          = chainon (current_binding_level->blocks, block);
-    }
+    current_binding_level->blocks
+      = chainon (current_binding_level->blocks, block);
+
   /* If we did not make a block for the level just exited,
      any blocks made for inner levels
      (since they cannot be recorded as subblocks in that level)
@@ -1664,9 +1613,11 @@ insert_block (block)
 
 void
 set_block (block)
-    register tree block;
+    tree block ATTRIBUTE_UNUSED;
 {
-  current_binding_level->this_block = block;
+  /* The RTL expansion machinery requires us to provide this callback,
+     but it is not applicable in function-at-a-time mode.  */
+  my_friendly_assert (cfun && !doing_semantic_analysis_p (), 20000911);
 }
 
 /* Do a pushlevel for class declarations.  */
@@ -1852,7 +1803,7 @@ walk_namespaces_r (namespace, f, data)
       if (!DECL_LANG_SPECIFIC (current))
        {
          /* Hmm. std. */
-         my_friendly_assert (current == std_node, 393);
+         my_friendly_assert (current == fake_std_node, 393);
          continue;
        }
 
@@ -1955,20 +1906,8 @@ wrapup_globals_for_namespace (namespace, data)
 
   /* Process the decls in reverse order--earliest first.
      Put them into VEC from back to front, then take out from front.  */
-
   for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
-    {
-      /* Pretend we've output an unused static variable.  This ensures
-         that the toplevel __FUNCTION__ etc won't be emitted, unless
-         needed. */
-      if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)
-         && !TREE_PUBLIC (decl) && !TREE_USED (decl))
-       {
-         TREE_ASM_WRITTEN (decl) = 1;
-         DECL_IGNORED_P (decl) = 1;
-       }
-      vec[len - i - 1] = decl;
-    }
+    vec[len - i - 1] = decl;
 
   if (last_time)
     {
@@ -2020,7 +1959,6 @@ mark_binding_level (arg)
       ggc_mark_tree (lvl->type_shadowed);
       ggc_mark_tree (lvl->shadowed_labels);
       ggc_mark_tree (lvl->blocks);
-      ggc_mark_tree (lvl->this_block);
       ggc_mark_tree (lvl->this_class);
       ggc_mark_tree (lvl->incomplete);
       ggc_mark_tree (lvl->dead_vars_from_for);
@@ -2348,9 +2286,10 @@ push_namespace (name)
       implicit_use = 1;
     }
   else if (current_namespace == global_namespace
-          && name == DECL_NAME (std_node))
+          && !flag_honor_std
+          && name == std_identifier)
     {
-      in_std++;
+      in_fake_std++;
       return;
     }
   else
@@ -2400,8 +2339,8 @@ pop_namespace ()
 {
   if (current_namespace == global_namespace)
     {
-      my_friendly_assert (in_std>0, 980421);
-      in_std--;
+      my_friendly_assert (in_fake_std > 0, 980421);
+      in_fake_std--;
       return;
     }
   current_namespace = CP_DECL_CONTEXT (current_namespace);
@@ -2449,16 +2388,6 @@ pop_nested_namespace (ns)
    scope isn't enough, because more binding levels may be pushed.  */
 struct saved_scope *scope_chain;
 
-/* Mark ST for GC.  */
-
-static void
-mark_stmt_tree (st)
-     struct stmt_tree *st;
-{
-  ggc_mark_tree (st->x_last_stmt);
-  ggc_mark_tree (st->x_last_expr_type);
-}
-
 /* Mark ARG (which is really a struct saved_scope **) for GC.  */
 
 static void
@@ -2478,7 +2407,6 @@ mark_saved_scope (arg)
       if (t->lang_base)
        ggc_mark_tree_varray (t->lang_base);
       ggc_mark_tree (t->lang_name);
-      ggc_mark_tree (t->x_function_parms);
       ggc_mark_tree (t->template_parms);
       ggc_mark_tree (t->x_previous_class_type);
       ggc_mark_tree (t->x_previous_class_values);
@@ -2497,6 +2425,8 @@ store_bindings (names, old_bindings)
      tree names, old_bindings;
 {
   tree t;
+  tree search_bindings = old_bindings;
+
   for (t = names; t; t = TREE_CHAIN (t))
     {
       tree binding, t1, id;
@@ -2513,22 +2443,18 @@ store_bindings (names, old_bindings)
          || !(IDENTIFIER_BINDING (id) || IDENTIFIER_CLASS_VALUE (id)))
        continue;
 
-      for (t1 = old_bindings; t1; t1 = TREE_CHAIN (t1))
+      for (t1 = search_bindings; t1; t1 = TREE_CHAIN (t1))
        if (TREE_VEC_ELT (t1, 0) == id)
          goto skip_it;
 
+      my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 135);
       binding = make_tree_vec (4);
-
-      if (id)
-       {
-         my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 135);
-         TREE_VEC_ELT (binding, 0) = id;
-         TREE_VEC_ELT (binding, 1) = REAL_IDENTIFIER_TYPE_VALUE (id);
-         TREE_VEC_ELT (binding, 2) = IDENTIFIER_BINDING (id);
-         TREE_VEC_ELT (binding, 3) = IDENTIFIER_CLASS_VALUE (id);
-         IDENTIFIER_BINDING (id) = NULL_TREE;
-         IDENTIFIER_CLASS_VALUE (id) = NULL_TREE;
-       }
+      TREE_VEC_ELT (binding, 0) = id;
+      TREE_VEC_ELT (binding, 1) = REAL_IDENTIFIER_TYPE_VALUE (id);
+      TREE_VEC_ELT (binding, 2) = IDENTIFIER_BINDING (id);
+      TREE_VEC_ELT (binding, 3) = IDENTIFIER_CLASS_VALUE (id);
+      IDENTIFIER_BINDING (id) = NULL_TREE;
+      IDENTIFIER_CLASS_VALUE (id) = NULL_TREE;
       TREE_CHAIN (binding) = old_bindings;
       old_bindings = binding;
     skip_it:
@@ -2622,12 +2548,10 @@ pop_from_top_level ()
   for (t = s->old_bindings; t; t = TREE_CHAIN (t))
     {
       tree id = TREE_VEC_ELT (t, 0);
-      if (id)
-       {
-         SET_IDENTIFIER_TYPE_VALUE (id, TREE_VEC_ELT (t, 1));
-         IDENTIFIER_BINDING (id) = TREE_VEC_ELT (t, 2);
-         IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3);
-       }
+
+      SET_IDENTIFIER_TYPE_VALUE (id, TREE_VEC_ELT (t, 1));
+      IDENTIFIER_BINDING (id) = TREE_VEC_ELT (t, 2);
+      IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3);
     }
 
   /* If we were in the middle of compiling a function, restore our
@@ -2900,12 +2824,12 @@ pushtag (name, type, globalize)
             all function definitions in a translation unit in a convenient
             way.  (It's otherwise tricky to find a member function definition
             it's only pointed to from within a local class.)  */
-         if (TYPE_CONTEXT (type) 
+         if (TYPE_CONTEXT (type)
              && TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL
              && !processing_template_decl)
            VARRAY_PUSH_TREE (local_classes, type);
 
-         if (!uses_template_parms (type)) 
+         if (!uses_template_parms (type))
            {
              if (flag_new_abi)
                DECL_ASSEMBLER_NAME (d) = mangle_type (type);
@@ -3464,7 +3388,7 @@ duplicate_decls (newdecl, olddecl)
        DECL_VIRTUAL_CONTEXT (newdecl) = DECL_VIRTUAL_CONTEXT (olddecl);
       if (DECL_CONTEXT (olddecl))
        DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
-      if (DECL_PENDING_INLINE_INFO (newdecl) == (struct pending_inline *)0)
+      if (DECL_PENDING_INLINE_INFO (newdecl) == 0)
        DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl);
       DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl);
       DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
@@ -3891,8 +3815,9 @@ pushdecl (x)
          /* Or in the innermost namespace.  */
          if (! t)
            t = namespace_binding (name, DECL_CONTEXT (x));
-         /* Does it have linkage?  */
-         if (t && ! (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+         /* Does it have linkage?  Note that if this isn't a DECL, it's an
+            OVERLOAD, which is OK.  */
+         if (t && DECL_P (t) && ! (TREE_STATIC (t) || DECL_EXTERNAL (t)))
            t = NULL_TREE;
          if (t)
            different_binding_level = 1;
@@ -4089,7 +4014,7 @@ pushdecl (x)
             warn if we later see static one.  */
          if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && TREE_PUBLIC (x))
            TREE_PUBLIC (name) = 1;
-         
+
          /* Bind the mangled name for the entity.  In the future, we
             should not need to do this; mangled names are an
             implementation detail of which the front-end should not
@@ -4785,7 +4710,7 @@ redeclaration_error_message (newdecl, olddecl)
   else if (TREE_CODE (newdecl) == TEMPLATE_DECL)
     {
       if ((TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == FUNCTION_DECL
-          && (DECL_TEMPLATE_RESULT (newdecl) 
+          && (DECL_TEMPLATE_RESULT (newdecl)
               != DECL_TEMPLATE_RESULT (olddecl))
           && DECL_INITIAL (DECL_TEMPLATE_RESULT (newdecl))
           && DECL_INITIAL (DECL_TEMPLATE_RESULT (olddecl)))
@@ -5138,14 +5063,16 @@ define_label (filename, line, name)
 {
   tree decl = lookup_label (name);
   struct named_label_list *ent;
+  register struct binding_level *p;
 
   for (ent = named_labels; ent; ent = ent->next)
     if (ent->label_decl == decl)
       break;
 
-  /* After labels, make any new cleanups go into their
+  /* After labels, make any new cleanups in the function go into their
      own new (temporary) binding contour.  */
-  current_binding_level->more_cleanups_ok = 0;
+  for (p = current_binding_level; !(p->parm_flag); p = p->level_chain)
+    p->more_cleanups_ok = 0;
 
   if (name == get_identifier ("wchar_t"))
     cp_pedwarn ("label named wchar_t");
@@ -5177,17 +5104,37 @@ struct cp_switch
 {
   struct binding_level *level;
   struct cp_switch *next;
+  /* The SWITCH_STMT being built.  */
+  tree switch_stmt;
+  /* A splay-tree mapping the low element of a case range to the high
+     element, or NULL_TREE if there is no high element.  Used to
+     determine whether or not a new case label duplicates an old case
+     label.  We need a tree, rather than simply a hash table, because
+     of the GNU case range extension.  */
+  splay_tree cases;
 };
 
+/* A stack of the currently active switch statements.  The innermost
+   switch statement is on the top of the stack.  There is no need to
+   mark the stack for garbage collection because it is only active
+   during the processing of the body of a function, and we never
+   collect at that point.  */
+
 static struct cp_switch *switch_stack;
 
+/* Called right after a switch-statement condition is parsed.
+   SWITCH_STMT is the switch statement being parsed.  */
+
 void
-push_switch ()
+push_switch (switch_stmt)
+     tree switch_stmt;
 {
   struct cp_switch *p
     = (struct cp_switch *) xmalloc (sizeof (struct cp_switch));
   p->level = current_binding_level;
   p->next = switch_stack;
+  p->switch_stmt = switch_stmt;
+  p->cases = splay_tree_new (case_compare, NULL, NULL);
   switch_stack = p;
 }
 
@@ -5195,8 +5142,9 @@ void
 pop_switch ()
 {
   struct cp_switch *cs;
-  
+
   cs = switch_stack;
+  splay_tree_delete (cs->cases);
   switch_stack = switch_stack->next;
   free (cs);
 }
@@ -5204,34 +5152,54 @@ pop_switch ()
 /* Note that we've seen a definition of a case label, and complain if this
    is a bad place for one.  */
 
-void
-define_case_label ()
+tree
+finish_case_label (low_value, high_value)
+     tree low_value;
+     tree high_value;
 {
-  tree cleanup = last_cleanup_this_contour ();
+  tree cond, r;
+  register struct binding_level *p;
 
   if (! switch_stack)
-    /* Don't crash; we'll complain in do_case.  */
-    return;
+    {
+      if (high_value)
+       error ("case label not within a switch statement");
+      else if (low_value)
+       cp_error ("case label `%E' not within a switch statement",
+                 low_value);
+      else
+       error ("`default' label not within a switch statement");
+      return NULL_TREE;
+    }
 
-  if (cleanup)
+  if (processing_template_decl)
     {
-      static int explained = 0;
-      cp_warning_at ("destructor needed for `%#D'", TREE_PURPOSE (cleanup));
-      warning ("where case label appears here");
-      if (!explained)
-       {
-         warning ("(enclose actions of previous case statements requiring destructors in their own scope.)");
-         explained = 1;
-       }
+      tree label;
+
+      /* For templates, just add the case label; we'll do semantic
+        analysis at instantiation-time.  */
+      label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+      return add_stmt (build_case_label (low_value, high_value, label));
     }
 
+  /* Find the condition on which this switch statement depends.  */
+  cond = SWITCH_COND (switch_stack->switch_stmt);
+  if (cond && TREE_CODE (cond) == TREE_LIST)
+    cond = TREE_VALUE (cond);
+
+  r = c_add_case_label (switch_stack->cases, cond, low_value, high_value);
+  if (r == error_mark_node)
+    r = NULL_TREE;
+
   check_switch_goto (switch_stack->level);
 
-  /* After labels, make any new cleanups go into their
+  /* After labels, make any new cleanups in the function go into their
      own new (temporary) binding contour.  */
-
-  current_binding_level->more_cleanups_ok = 0;
+  for (p = current_binding_level; !(p->parm_flag); p = p->level_chain)
+    p->more_cleanups_ok = 0;
   current_function_return_value = NULL_TREE;
+
+  return r;
 }
 \f
 /* Return the list of declarations of the current level.
@@ -5698,6 +5666,15 @@ select_decl (binding, flags)
 {
   tree val;
   val = BINDING_VALUE (binding);
+
+  /* When we implicitly declare some builtin entity, we mark it
+     DECL_ANTICIPATED, so that we know to ignore it until it is
+     really declared.  */
+  if (val && DECL_P (val)
+      && DECL_LANG_SPECIFIC (val)
+      && DECL_ANTICIPATED (val))
+    return NULL_TREE;
+
   if (LOOKUP_NAMESPACES_ONLY (flags))
     {
       /* We are not interested in types. */
@@ -5887,7 +5864,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
         flags |= LOOKUP_TEMPLATES_EXPECTED;
 
       /* std:: becomes :: for now.  */
-      if (got_scope == std_node)
+      if (got_scope && got_scope == fake_std_node)
        got_scope = void_type_node;
 
       if (got_scope)
@@ -5942,7 +5919,10 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
       if (got_scope)
        goto done;
       else if (got_object && val)
-       from_obj = val;
+       {
+         from_obj = val;
+         val = NULL_TREE;
+       }
     }
   else
     {
@@ -6011,13 +5991,12 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
        {
          if (looking_for_typename && TREE_CODE (from_obj) == TYPE_DECL
              && TREE_CODE (val) == TYPE_DECL
-             && TREE_TYPE (from_obj) != TREE_TYPE (val))
-           {
-             cp_pedwarn ("lookup of `%D' in the scope of `%#T' (`%#T')",
-                         name, got_object, TREE_TYPE (from_obj));
-             cp_pedwarn ("  does not match lookup in the current scope (`%#T')",
-                         TREE_TYPE (val));
-           }
+             && ! same_type_p (TREE_TYPE (from_obj), TREE_TYPE (val)))
+           cp_pedwarn ("\
+lookup of `%D' in the scope of `%#T' (`%#T') \
+does not match lookup in the current scope (`%#T')",
+                       name, got_object, TREE_TYPE (from_obj),
+                       TREE_TYPE (val));
 
          /* We don't change val to from_obj if got_object depends on
             template parms because that breaks implicit typename for
@@ -6148,7 +6127,7 @@ end_only_namespace_names ()
 }
 \f
 /* Push the declarations of builtin types into the namespace.
-   RID_INDEX, if < CP_RID_MAX is the index of the builtin type
+   RID_INDEX is the index of the builtin type
    in the array RID_POINTERS.  NAME is the name used when looking
    up the builtin type.  TYPE is the _TYPE node for the builtin type.  */
 
@@ -6161,7 +6140,7 @@ record_builtin_type (rid_index, name, type)
   tree rname = NULL_TREE, tname = NULL_TREE;
   tree tdecl = NULL_TREE;
 
-  if ((int) rid_index < (int) CP_RID_MAX)
+  if ((int) rid_index < (int) RID_MAX)
     rname = ridpointers[(int) rid_index];
   if (name)
     tname = get_identifier (name);
@@ -6172,7 +6151,7 @@ record_builtin_type (rid_index, name, type)
     {
       tdecl = pushdecl (build_decl (TYPE_DECL, tname, type));
       set_identifier_type_value (tname, NULL_TREE);
-      if ((int) rid_index < (int) CP_RID_MAX)
+      if ((int) rid_index < (int) RID_MAX)
        /* Built-in types live in the global namespace. */
        SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
     }
@@ -6215,7 +6194,7 @@ record_builtin_java_type (name, size)
       TYPE_PRECISION (type) = - size;
       layout_type (type);
     }
-  record_builtin_type (CP_RID_MAX, name, type);
+  record_builtin_type (RID_MAX, name, type);
   decl = TYPE_NAME (type);
 
   /* Suppress generate debug symbol entries for these types,
@@ -6260,7 +6239,7 @@ typedef struct predefined_identifier
 /* Create all the predefined identifiers.  */
 
 static void
-initialize_predefined_identifiers () 
+initialize_predefined_identifiers ()
 {
   struct predefined_identifier *pid;
 
@@ -6319,11 +6298,12 @@ init_decl_processing ()
   /* Create all the identifiers we need.  */
   initialize_predefined_identifiers ();
 
-  /* Let the back-end now how to save and restore language-specific
-     per-function globals.  */
+  /* Fill in back-end hooks.  */
   init_lang_status = &push_cp_function_context;
   free_lang_status = &pop_cp_function_context;
   mark_lang_status = &mark_cp_function_context;
+  lang_safe_from_p = &c_safe_from_p;
+  lang_dump_tree = &cp_dump_tree;
 
   cp_parse_init ();
   init_decl2 ();
@@ -6363,6 +6343,22 @@ init_decl_processing ()
   NAMESPACE_LEVEL (global_namespace) = global_binding_level;
   declare_namespace_level ();
 
+  /* Create the `std' namespace.  */
+  if (flag_honor_std)
+    {
+      push_namespace (std_identifier);
+      std_node = current_namespace;
+      pop_namespace ();
+      fake_std_node = error_mark_node;
+    }
+  else
+    {
+      fake_std_node = build_decl (NAMESPACE_DECL,
+                                 std_identifier,
+                                 void_type_node);
+      pushdecl (fake_std_node);
+    }
+
   /* Define `int' and `char' first so that dbx will output them first.  */
   record_builtin_type (RID_INT, NULL_PTR, integer_type_node);
   record_builtin_type (RID_CHAR, "char", char_type_node);
@@ -6371,33 +6367,32 @@ init_decl_processing ()
   record_builtin_type (RID_SIGNED, NULL_PTR, integer_type_node);
   record_builtin_type (RID_LONG, "long int", long_integer_type_node);
   record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
-  record_builtin_type (CP_RID_MAX, "long unsigned int",
+  record_builtin_type (RID_MAX, "long unsigned int",
                       long_unsigned_type_node);
-  record_builtin_type (CP_RID_MAX, "unsigned long", long_unsigned_type_node);
-  record_builtin_type (CP_RID_MAX, "long long int",
+  record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
+  record_builtin_type (RID_MAX, "long long int",
                       long_long_integer_type_node);
-  record_builtin_type (CP_RID_MAX, "long long unsigned int",
+  record_builtin_type (RID_MAX, "long long unsigned int",
                       long_long_unsigned_type_node);
-  record_builtin_type (CP_RID_MAX, "long long unsigned",
+  record_builtin_type (RID_MAX, "long long unsigned",
                       long_long_unsigned_type_node);
   record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
-  record_builtin_type (CP_RID_MAX, "short unsigned int",
-                      short_unsigned_type_node); 
-  record_builtin_type (CP_RID_MAX, "unsigned short",
+  record_builtin_type (RID_MAX, "short unsigned int",
+                      short_unsigned_type_node);
+  record_builtin_type (RID_MAX, "unsigned short",
                       short_unsigned_type_node);
-
-  ptrdiff_type_node
-    = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
 
   /* Define both `signed char' and `unsigned char'.  */
-  record_builtin_type (CP_RID_MAX, "signed char", signed_char_type_node);
-  record_builtin_type (CP_RID_MAX, "unsigned char", unsigned_char_type_node);
+  record_builtin_type (RID_MAX, "signed char", signed_char_type_node);
+  record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
 
   /* `unsigned long' is the standard type for sizeof.
      Note that stddef.h uses `unsigned long',
      and this must agree, even if long and int are the same size.  */
-  set_sizetype
-    (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE))));
+  c_size_type_node =
+    TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
+  signed_size_type_node = signed_type (c_size_type_node);
+  set_sizetype (c_size_type_node);
 
   /* Create the widest literal types. */
   widest_integer_literal_type_node = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
@@ -6454,7 +6449,7 @@ init_decl_processing ()
   signed_size_zero_node = build_int_2 (0, 0);
   record_builtin_type (RID_FLOAT, NULL_PTR, float_type_node);
   record_builtin_type (RID_DOUBLE, NULL_PTR, double_type_node);
-  record_builtin_type (CP_RID_MAX, "long double", long_double_type_node);
+  record_builtin_type (RID_MAX, "long double", long_double_type_node);
 
   pushdecl (build_decl (TYPE_DECL, get_identifier ("complex int"),
                        complex_integer_type_node));
@@ -6471,19 +6466,7 @@ init_decl_processing ()
   void_list_node = build_tree_list (NULL_TREE, void_type_node);
   TREE_PARMLIST (void_list_node) = 1;
 
-  /* Used for expressions that do nothing, but are not errors.  */
-  void_zero_node = build_int_2 (0, 0);
-  TREE_TYPE (void_zero_node) = void_type_node;
-
-  string_type_node = build_pointer_type (char_type_node);
-  const_string_type_node
-    = build_pointer_type (build_qualified_type (char_type_node,
-                                               TYPE_QUAL_CONST));
   empty_except_spec = build_tree_list (NULL_TREE, NULL_TREE);
-#if 0
-  record_builtin_type (CP_RID_MAX, NULL_PTR, string_type_node);
-#endif
-
   /* Make a type to be the domain of a few array types
      whose domains don't really matter.
      200 is small enough that it always fits in size_t.  */
@@ -6499,6 +6482,12 @@ init_decl_processing ()
   int_array_type_node
     = build_array_type (integer_type_node, array_domain_type);
 
+  c_common_nodes_and_builtins ();
+
+#if 0
+  record_builtin_type (RID_MAX, NULL_PTR, string_type_node);
+#endif
+
   if (flag_new_abi)
     delta_type_node = ptrdiff_type_node;
   else if (flag_huge_objects)
@@ -6511,20 +6500,16 @@ init_decl_processing ()
   else
     vtable_index_type = delta_type_node;
 
-  default_function_type
-    = build_function_type (integer_type_node, NULL_TREE);
-
-  ptr_type_node = build_pointer_type (void_type_node);
-  const_ptr_type_node
-    = build_pointer_type (build_qualified_type (void_type_node,
-                                               TYPE_QUAL_CONST));
   vtt_parm_type = build_pointer_type (const_ptr_type_node);
-  c_common_nodes_and_builtins (1, flag_no_builtin, flag_no_nonansi_builtin);
   lang_type_promotes_to = convert_type_from_ellipsis;
 
   void_ftype_ptr
     = build_exception_variant (void_ftype_ptr, empty_except_spec);
 
+#ifdef MD_INIT_BUILTINS
+  MD_INIT_BUILTINS;
+#endif
+
   /* C++ extensions */
 
   unknown_type_node = make_node (UNKNOWN_TYPE);
@@ -6550,12 +6535,7 @@ init_decl_processing ()
     wchar_type_node = make_signed_type (wchar_type_size);
   else
     wchar_type_node = make_unsigned_type (wchar_type_size);
-  record_builtin_type (RID_WCHAR, "__wchar_t", wchar_type_node);
-
-  /* Artificial declaration of wchar_t -- can be bashed */
-  wchar_decl_node = build_decl (TYPE_DECL, get_identifier ("wchar_t"),
-                               wchar_type_node);
-  pushdecl (wchar_decl_node);
+  record_builtin_type (RID_WCHAR, "wchar_t", wchar_type_node);
 
   /* This is for wide string constants.  */
   wchar_array_type_node
@@ -6596,23 +6576,17 @@ init_decl_processing ()
       vtable_entry_type = build_qualified_type (vtable_entry_type,
                                                TYPE_QUAL_CONST);
     }
-  record_builtin_type (CP_RID_MAX, VTBL_PTR_TYPE, vtable_entry_type);
+  record_builtin_type (RID_MAX, VTBL_PTR_TYPE, vtable_entry_type);
 
   vtbl_type_node
     = build_cplus_array_type (vtable_entry_type, NULL_TREE);
   layout_type (vtbl_type_node);
   vtbl_type_node = build_qualified_type (vtbl_type_node, TYPE_QUAL_CONST);
-  record_builtin_type (CP_RID_MAX, NULL_PTR, vtbl_type_node);
+  record_builtin_type (RID_MAX, NULL_PTR, vtbl_type_node);
   vtbl_ptr_type_node = build_pointer_type (vtable_entry_type);
   layout_type (vtbl_ptr_type_node);
-  record_builtin_type (CP_RID_MAX, NULL_PTR, vtbl_ptr_type_node);
+  record_builtin_type (RID_MAX, NULL_PTR, vtbl_ptr_type_node);
 
-  std_node = build_decl (NAMESPACE_DECL,
-                        flag_honor_std 
-                        ? get_identifier ("fake std") : std_identifier,
-                        void_type_node);
-  pushdecl (std_node);
-  
   if (flag_new_abi)
     {
       push_namespace (get_identifier ("__cxxabiv1"));
@@ -6629,7 +6603,7 @@ init_decl_processing ()
   {
     tree bad_alloc_type_node, newtype, deltype;
     if (flag_honor_std)
-      push_namespace (get_identifier ("std"));
+      push_namespace (std_identifier);
     bad_alloc_type_node = xref_tag
       (class_type_node, get_identifier ("bad_alloc"), 1);
     if (flag_honor_std)
@@ -6644,7 +6618,10 @@ init_decl_processing ()
   }
 
   abort_fndecl
-    = build_library_fn_ptr ("__pure_virtual", void_ftype);
+    = build_library_fn_ptr ((flag_new_abi 
+                            ? "__cxa_pure_virtual"
+                            : "__pure_virtual"),
+                           void_ftype);
 
   /* Perform other language dependent initializations.  */
   init_class_processing ();
@@ -6700,7 +6677,6 @@ init_decl_processing ()
 
   ggc_add_tree_root (&last_function_parm_tags, 1);
   ggc_add_tree_root (&current_function_return_value, 1);
-  ggc_add_tree_root (&current_function_parms, 1);
   ggc_add_tree_root (&current_function_parm_tags, 1);
   ggc_add_tree_root (&last_function_parms, 1);
   ggc_add_tree_root (&error_mark_list, 1);
@@ -6733,7 +6709,7 @@ cp_make_fname_decl (id, name, type_dep)
   tree decl, type, init;
   size_t length = strlen (name);
   tree domain = NULL_TREE;
-  
+
   if (!processing_template_decl)
     type_dep = 0;
   if (!type_dep)
@@ -6764,7 +6740,7 @@ cp_make_fname_decl (id, name, type_dep)
     }
   DECL_INITIAL (decl) = init;
   cp_finish_decl (decl, init, NULL_TREE, LOOKUP_ONLYCONVERTING);
-  
+
   /* We will have to make sure we only emit this, if it is actually used. */
   return decl;
 }
@@ -6794,10 +6770,20 @@ builtin_function (name, type, code, class, libname)
 
   my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 392);
 
+  /* All builtins that don't begin with an `_' should go in the `std'
+     namespace.  */
+  if (flag_honor_std && name[0] != '_')
+    {
+      push_namespace (std_identifier);
+      DECL_CONTEXT (decl) = std_node;
+    }
+  pushdecl (decl);
+  if (flag_honor_std && name[0] != '_')
+    pop_namespace ();
+
   /* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME,
      we cannot change DECL_ASSEMBLER_NAME until we have installed this
      function in the namespace.  */
-  pushdecl (decl);
   if (libname)
     DECL_ASSEMBLER_NAME (decl) = get_identifier (libname);
   make_function_rtl (decl);
@@ -6900,7 +6886,7 @@ push_cp_library_fn (operator_code, type)
      enum tree_code operator_code;
      tree type;
 {
-  tree fn = build_cp_library_fn (ansi_opname (operator_code), 
+  tree fn = build_cp_library_fn (ansi_opname (operator_code),
                                 operator_code,
                                 type);
   pushdecl (fn);
@@ -7149,8 +7135,8 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
   /* This should only be done once on the top most decl.  */
   if (have_extern_spec && !used_extern_spec)
     {
-      declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"),
-                                 declspecs);
+      declspecs = tree_cons (NULL_TREE, get_identifier ("extern"),
+                            declspecs);
       used_extern_spec = 1;
     }
 
@@ -7362,7 +7348,7 @@ start_decl_1 (decl)
       && TREE_CODE (decl) != TYPE_DECL
       && TREE_CODE (decl) != TEMPLATE_DECL
       && type != error_mark_node
-      && IS_AGGR_TYPE (type) 
+      && IS_AGGR_TYPE (type)
       && ! DECL_EXTERNAL (decl))
     {
       if ((! processing_template_decl || ! uses_template_parms (type))
@@ -7516,12 +7502,9 @@ maybe_deduce_size_from_array_init (decl, init)
       && TYPE_DOMAIN (type) == NULL_TREE
       && TREE_CODE (decl) != TYPE_DECL)
     {
-      int do_default
-       = (TREE_STATIC (decl)
-          /* Even if pedantic, an external linkage array
-             may have incomplete type at first.  */
-          ? pedantic && ! DECL_EXTERNAL (decl)
-          : !DECL_EXTERNAL (decl));
+      /* do_default is really a C-ism to deal with tentative definitions.
+        But let's leave it here to ease the eventual merge.  */
+      int do_default = !DECL_EXTERNAL (decl);
       tree initializer = init ? init : DECL_INITIAL (decl);
       int failure = complete_array_type (type, initializer, do_default);
 
@@ -7625,6 +7608,7 @@ maybe_commonize_var (decl)
         inlining of such functions.  */
       current_function_cannot_inline
        = "function with static variable cannot be inline";
+      DECL_UNINLINABLE (current_function_decl) = 1;
 
       /* If flag_weak, we don't need to mess with this, as we can just
         make the function weak, and let it refer to its unique local
@@ -7888,7 +7872,7 @@ maybe_inject_for_scope_var (decl)
 {
   if (!DECL_NAME (decl))
     return;
-  
+
   if (current_binding_level->is_for_scope)
     {
       struct binding_level *outer
@@ -7962,15 +7946,12 @@ initialize_local_var (decl, init, flags)
        {
          int saved_stmts_are_full_exprs_p;
 
-         emit_line_note (DECL_SOURCE_FILE (decl),
-                         DECL_SOURCE_LINE (decl));
+         my_friendly_assert (building_stmt_tree (), 20000906);
          saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
-         current_stmt_tree->stmts_are_full_exprs_p = 1;
-         if (building_stmt_tree ())
-           finish_expr_stmt (build_aggr_init (decl, init, flags));
-         else
-           genrtl_expr_stmt (build_aggr_init (decl, init, flags));
-         current_stmt_tree->stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
+         current_stmt_tree ()->stmts_are_full_exprs_p = 1;
+         finish_expr_stmt (build_aggr_init (decl, init, flags));
+         current_stmt_tree ()->stmts_are_full_exprs_p =
+           saved_stmts_are_full_exprs_p;
        }
 
       /* Set this to 0 so we can tell whether an aggregate which was
@@ -8083,9 +8064,9 @@ cp_finish_decl (decl, init, asmspec_tree, flags)
 
   if (type == error_mark_node)
     return;
-  
+
   /* Add this declaration to the statement-tree.  */
-  if (building_stmt_tree () 
+  if (building_stmt_tree ()
       && at_function_scope_p ()
       && TREE_CODE (decl) != RESULT_DECL)
     add_decl_stmt (decl);
@@ -8925,6 +8906,9 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
           orig_declarator);
       else
        {
+         tree fns = TREE_OPERAND (orig_declarator, 0);
+         tree args = TREE_OPERAND (orig_declarator, 1);
+         
          if (PROCESSING_REAL_TEMPLATE_DECL_P ())
            {
              /* Something like `template <class T> friend void f<T>()'.  */
@@ -8937,10 +8921,22 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
          /* A friend declaration of the form friend void f<>().  Record
             the information in the TEMPLATE_ID_EXPR.  */
          SET_DECL_IMPLICIT_INSTANTIATION (decl);
-         DECL_TEMPLATE_INFO (decl)
-           = tree_cons (TREE_OPERAND (orig_declarator, 0),
-                        TREE_OPERAND (orig_declarator, 1),
-                        NULL_TREE);
+
+          if (TREE_CODE (fns) == COMPONENT_REF)
+            {
+              /* Due to bison parser ickiness, we will have already looked
+                 up an operator_name or PFUNCNAME within the current class
+                 (see template_id in parse.y). If the current class contains
+                 such a name, we'll get a COMPONENT_REF here. Undo that. */
+              
+              my_friendly_assert (TREE_TYPE (TREE_OPERAND (fns, 0))
+                                  == current_class_type, 20001120);
+              fns = TREE_OPERAND (fns, 1);
+            }
+         my_friendly_assert (TREE_CODE (fns) == IDENTIFIER_NODE
+                             || TREE_CODE (fns) == LOOKUP_EXPR
+                             || TREE_CODE (fns) == OVERLOAD, 20001120);
+         DECL_TEMPLATE_INFO (decl) = tree_cons (fns, args, NULL_TREE);
 
          if (has_default_arg)
            {
@@ -9044,12 +9040,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
     return decl;
 
   if (virtualp)
-    {
-      DECL_VIRTUAL_P (decl) = 1;
-      if (DECL_VINDEX (decl) == NULL_TREE)
-       DECL_VINDEX (decl) = error_mark_node;
-      IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
-    }
+    DECL_VIRTUAL_P (decl) = 1;
 
   return decl;
 }
@@ -9109,12 +9100,12 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
        set_decl_namespace (decl, context, 0);
 
       context = DECL_CONTEXT (decl);
-      if (declarator && context && current_lang_name != lang_name_c) 
+      if (declarator && context && current_lang_name != lang_name_c)
        {
          if (flag_new_abi)
            DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
          else
-           DECL_ASSEMBLER_NAME (decl) 
+           DECL_ASSEMBLER_NAME (decl)
              = build_static_name (context, declarator);
        }
     }
@@ -9184,6 +9175,9 @@ build_ptrmemfunc_type (type)
   tree u;
   tree unqualified_variant = NULL_TREE;
 
+  if (type == error_mark_node)
+    return type;
+  
   /* If a canonical type already exists for this type, use it.  We use
      this method instead of type_hash_canon, because it only does a
      simple equality check on the list of field members.  */
@@ -9516,7 +9510,7 @@ check_special_function_return_type (sfk, type, ctype, optype)
     case sfk_constructor:
       if (type)
        cp_error ("return type specification for constructor invalid");
-       
+
       /* In the old ABI, we return `this'; in the new ABI we don't
         bother.  */
       type = flag_new_abi ? void_type_node : build_pointer_type        (ctype);
@@ -9822,7 +9816,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
 
            next = 0;
 
-           if (is_rid (dname))
+           if (C_IS_RESERVED_WORD (dname))
              {
                cp_error ("declarator-id missing; using reserved word `%D'",
                          dname);
@@ -9837,7 +9831,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                ctor_return_type = TREE_TYPE (dname);
                sfk = sfk_conversion;
                if (IDENTIFIER_GLOBAL_VALUE (dname)
-                   && (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (dname)) 
+                   && (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (dname))
                        == TYPE_DECL))
                  name = IDENTIFIER_POINTER (dname);
                else
@@ -10408,7 +10402,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                  if (IDENTIFIER_TYPENAME_P (tmp))
                    {
                      if (IDENTIFIER_GLOBAL_VALUE (tmp)
-                         && (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (tmp)) 
+                         && (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (tmp))
                              == TYPE_DECL))
                        name = IDENTIFIER_POINTER (tmp);
                      else
@@ -10551,7 +10545,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            type = create_array_type_for_decl (dname, type, size);
 
            /* VLAs never work as fields. */
-           if (decl_context == FIELD && !processing_template_decl 
+           if (decl_context == FIELD && !processing_template_decl
                && TREE_CODE (type) == ARRAY_TYPE
                && TYPE_DOMAIN (type) != NULL_TREE
                && !TREE_CONSTANT (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
@@ -10673,7 +10667,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                      }
                    {
                      RID_BIT_TYPE tmp_bits;
-                     bcopy ((void*)&specbits, (void*)&tmp_bits, sizeof (RID_BIT_TYPE));
+                     memcpy (&tmp_bits, &specbits, sizeof (RID_BIT_TYPE));
                      RIDBIT_RESET (RID_INLINE, tmp_bits);
                      RIDBIT_RESET (RID_STATIC, tmp_bits);
                      if (RIDBIT_ANY_SET (tmp_bits))
@@ -10719,7 +10713,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            /* FIXME: This is where default args should be fully
               processed.  */
 
-           arg_types = grokparms (inner_parms, funcdecl_p ? funcdef_flag : 0);
+           arg_types = grokparms (inner_parms);
 
            if (declarator && flags == DTOR_FLAG)
              {
@@ -10914,7 +10908,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            t = ctype;
            while (t != NULL_TREE && CLASS_TYPE_P (t))
              {
-               /* You're supposed to have one `template <...>' 
+               /* You're supposed to have one `template <...>'
                   for every template class, but you don't need one
                   for a full specialization.  For example:
 
@@ -10958,8 +10952,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                  }
                else if (TREE_CODE (type) == FUNCTION_TYPE)
                  {
-                   if (current_class_type == NULL_TREE
-                       || friendp)
+                   if (current_class_type == NULL_TREE || friendp)
                      type = build_cplus_method_type (ctype, TREE_TYPE (type),
                                                      TYPE_ARG_TYPES (type));
                    else
@@ -10985,18 +10978,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                      }
                    type = build_offset_type (ctype, type);
                  }
-               else if (uses_template_parms (ctype))
-                 {
-                    if (TREE_CODE (type) == FUNCTION_TYPE)
-                     type
-                       = build_cplus_method_type (ctype, TREE_TYPE (type),
-                                                  TYPE_ARG_TYPES (type));
-                 }
                else
-                 {
-                   cp_error ("structure `%T' not yet defined", ctype);
-                   return error_mark_node;
-                 }
+                 {
+                   incomplete_type_error (NULL_TREE, ctype);
+                   return error_mark_node;
+                 }
 
                declarator = sname;
              }
@@ -11048,7 +11034,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
       else if (attrlist)
        TREE_VALUE (attrlist) = chainon (inner_attrs, TREE_VALUE (attrlist));
       else
-       attrlist = build_decl_list (NULL_TREE, inner_attrs);
+       attrlist = build_tree_list (NULL_TREE, inner_attrs);
     }
 
   /* Now TYPE has the actual type.  */
@@ -11157,7 +11143,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            DECL_NAME (CLASSTYPE_TI_TEMPLATE (type))
              = TYPE_IDENTIFIER (type);
 
-         if (flag_new_abi) 
+         if (flag_new_abi)
            DECL_ASSEMBLER_NAME (decl) = mangle_type (type);
          else
            {
@@ -11169,7 +11155,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                DECL_CONTEXT (decl) = current_class_type;
              else
                DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
-             
+
              DECL_ASSEMBLER_NAME (decl) = DECL_NAME (decl);
              DECL_ASSEMBLER_NAME (decl)
                = get_identifier (build_overload_name (type, 1, 1));
@@ -11246,23 +11232,37 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
              cp_error ("`inline' specified for friend class declaration");
              inlinep = 0;
            }
-         if (!current_aggr && TREE_CODE (type) != TYPENAME_TYPE)
+
+         /* Until core issue 180 is resolved, allow 'friend typename A::B'.
+            But don't allow implicit typenames except with a class-key.  */
+         if (!current_aggr && (TREE_CODE (type) != TYPENAME_TYPE
+                               || IMPLICIT_TYPENAME_P (type)))
            {
              if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
-               cp_error ("template parameters cannot be friends");
+               cp_pedwarn ("template parameters cannot be friends");
+             else if (TREE_CODE (type) == TYPENAME_TYPE)
+               cp_pedwarn ("\
+friend declaration requires class-key, i.e. `friend class %T::%T'",
+                           constructor_name (current_class_type),
+                           TYPE_IDENTIFIER (type));
              else
-               cp_error ("friend declaration requires `%#T'", type);
+               cp_pedwarn ("\
+friend declaration requires class-key, i.e. `friend %#T'",
+                           type);
            }
 
          /* Only try to do this stuff if we didn't already give up.  */
          if (type != integer_type_node)
            {
+             decl_type_access_control (TYPE_NAME (type));
+             
              /* A friendly class?  */
              if (current_class_type)
                make_friend_class (current_class_type, TYPE_MAIN_VARIANT (type));
              else
                cp_error ("trying to make class `%T' a friend of global scope",
                          type);
+              
              type = void_type_node;
            }
        }
@@ -11337,11 +11337,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
        type = build_pointer_type (type);
       else if (TREE_CODE (type) == OFFSET_TYPE)
        type = build_pointer_type (type);
-      else if (TREE_CODE (type) == VOID_TYPE && declarator)
-       {
-         error ("declaration of `%s' as void", name);
-         return NULL_TREE;
-       }
     }
 
   {
@@ -11807,25 +11802,13 @@ require_complete_types_for_parms (parms)
 {
   for (; parms; parms = TREE_CHAIN (parms))
     {
-      tree type = TREE_TYPE (parms);
-
-      /* Try to complete the TYPE.  */
-      type = complete_type (type);
-
-      if (type == error_mark_node)
-       continue;
-
-      if (!COMPLETE_TYPE_P (type))
-       {
-         if (DECL_NAME (parms))
-           error ("parameter `%s' has incomplete type",
-                  IDENTIFIER_POINTER (DECL_NAME (parms)));
-         else
-           error ("parameter has incomplete type");
-         TREE_TYPE (parms) = error_mark_node;
-       }
-      else
+      if (VOID_TYPE_P (TREE_TYPE (parms)))
+        /* grokparms will have already issued an error */
+        TREE_TYPE (parms) = error_mark_node;
+      else if (complete_type_or_else (TREE_TYPE (parms), parms))
        layout_decl (parms, 0);
+      else
+        TREE_TYPE (parms) = error_mark_node;
     }
 }
 
@@ -11939,7 +11922,7 @@ check_default_argument (decl, arg)
 
      The keyword `this' shall not be used in a default argument of a
      member function.  */
-  var = walk_tree_without_duplicates (&arg, local_variable_p_walkfn, 
+  var = walk_tree_without_duplicates (&arg, local_variable_p_walkfn,
                                      NULL);
   if (var)
     {
@@ -11956,205 +11939,120 @@ check_default_argument (decl, arg)
    Given the list of things declared inside the parens,
    return a list of types.
 
-   The list we receive can have three kinds of elements:
-   an IDENTIFIER_NODE for names given without types,
-   a TREE_LIST node for arguments given as typespecs or names with typespecs,
-   or void_type_node, to mark the end of an argument list
-   when additional arguments are not permitted (... was not used).
-
-   FUNCDEF_FLAG is nonzero for a function definition, 0 for
-   a mere declaration.  A nonempty identifier-list gets an error message
-   when FUNCDEF_FLAG is zero.
-   If FUNCDEF_FLAG is 1, then parameter types must be complete.
-   If FUNCDEF_FLAG is -1, then parameter types may be incomplete.
-
-   If all elements of the input list contain types,
-   we return a list of the types.
-   If all elements contain no type (except perhaps a void_type_node
-   at the end), we return a null list.
-   If some have types and some do not, it is an error, and we
-   return a null list.
-
-   Also set last_function_parms to either
-   a list of names (IDENTIFIER_NODEs) or a chain of PARM_DECLs.
-   A list of names is converted to a chain of PARM_DECLs
-   by store_parm_decls so that ultimately it is always a chain of decls.
-
-   Note that in C++, parameters can take default values.  These default
-   values are in the TREE_PURPOSE field of the TREE_LIST.  It is
-   an error to specify default values which are followed by parameters
-   that have no default values, or an ELLIPSES.  For simplicities sake,
-   only parameters which are specified with their types can take on
-   default values.  */
+   We determine whether ellipsis parms are used by PARMLIST_ELLIPSIS_P
+   flag. If unset, we append void_list_node. A parmlist declared
+   as `(void)' is accepted as the empty parmlist.
+
+   Also set last_function_parms to the chain of PARM_DECLs.  */
 
 static tree
-grokparms (first_parm, funcdef_flag)
+grokparms (first_parm)
      tree first_parm;
-     int funcdef_flag;
 {
   tree result = NULL_TREE;
   tree decls = NULL_TREE;
+  int ellipsis = !first_parm || PARMLIST_ELLIPSIS_P (first_parm);
+  tree parm, chain;
+  int any_error = 0;
 
-  if (first_parm != NULL_TREE
-      && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
-    {
-      if (! funcdef_flag)
-       pedwarn ("parameter names (without types) in function declaration");
-      last_function_parms = first_parm;
-      return NULL_TREE;
-    }
-  else if (first_parm != NULL_TREE
-          && TREE_CODE (TREE_VALUE (first_parm)) != TREE_LIST
-          && TREE_CODE (TREE_VALUE (first_parm)) != VOID_TYPE)
-    my_friendly_abort (145);
-  else
-    {
-      /* Types were specified.  This is a list of declarators
-        each represented as a TREE_LIST node.  */
-      register tree parm, chain;
-      int any_init = 0, any_error = 0;
-
-      if (first_parm != NULL_TREE)
-       {
-         tree last_result = NULL_TREE;
-         tree last_decl = NULL_TREE;
+  my_friendly_assert (!first_parm || TREE_PARMLIST (first_parm), 20001115);
 
-         for (parm = first_parm; parm != NULL_TREE; parm = chain)
-           {
-             tree type = NULL_TREE, list_node = parm;
-             register tree decl = TREE_VALUE (parm);
-             tree init = TREE_PURPOSE (parm);
-
-             chain = TREE_CHAIN (parm);
-             /* @@ weak defense against parse errors.  */
-             if (TREE_CODE (decl) != VOID_TYPE
-                 && TREE_CODE (decl) != TREE_LIST)
-               {
-                 /* Give various messages as the need arises.  */
-                 if (TREE_CODE (decl) == STRING_CST)
-                   cp_error ("invalid string constant `%E'", decl);
-                 else if (TREE_CODE (decl) == INTEGER_CST)
-                   error ("invalid integer constant in parameter list, did you forget to give parameter name?");
-                 continue;
-               }
-
-             if (TREE_CODE (decl) != VOID_TYPE)
-               {
-                 decl = grokdeclarator (TREE_VALUE (decl),
-                                        TREE_PURPOSE (decl),
-                                        PARM, init != NULL_TREE,
-                                        NULL_TREE);
-                 if (! decl || TREE_TYPE (decl) == error_mark_node)
-                   continue;
-
-                 /* Top-level qualifiers on the parameters are
-                    ignored for function types.  */
-                 type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
-
-                 if (TREE_CODE (type) == VOID_TYPE)
-                   decl = void_type_node;
-                 else if (TREE_CODE (type) == METHOD_TYPE)
-                   {
-                     if (DECL_NAME (decl))
-                       /* Cannot use the decl here because
-                          we don't have DECL_CONTEXT set up yet.  */
-                       cp_error ("parameter `%D' invalidly declared method type",
-                                 DECL_NAME (decl));
-                     else
-                       error ("parameter invalidly declared method type");
-                     type = build_pointer_type (type);
-                     TREE_TYPE (decl) = type;
-                   }
-                 else if (TREE_CODE (type) == OFFSET_TYPE)
-                   {
-                     if (DECL_NAME (decl))
-                       cp_error ("parameter `%D' invalidly declared offset type",
-                                 DECL_NAME (decl));
-                     else
-                       error ("parameter invalidly declared offset type");
-                     type = build_pointer_type (type);
-                     TREE_TYPE (decl) = type;
-                   }
-                  else if (abstract_virtuals_error (decl, type))
-                   any_error = 1;  /* Seems like a good idea. */
-                 else if (POINTER_TYPE_P (type))
-                   {
-                     tree t = type;
-                     while (POINTER_TYPE_P (t)
-                            || (TREE_CODE (t) == ARRAY_TYPE
-                                && TYPE_DOMAIN (t) != NULL_TREE))
-                       t = TREE_TYPE (t);
-                     if (TREE_CODE (t) == ARRAY_TYPE)
-                       cp_error ("parameter type `%T' includes %s to array of unknown bound",
-                                 type,
-                                 TYPE_PTR_P (type) ? "pointer" : "reference");
-                   }
-               }
+  for (parm = first_parm; parm != NULL_TREE; parm = chain)
+    {
+      tree type = NULL_TREE;
+      register tree decl = TREE_VALUE (parm);
+      tree init = TREE_PURPOSE (parm);
+
+      chain = TREE_CHAIN (parm);
+      /* @@ weak defense against parse errors.  */
+      if (TREE_CODE (decl) != VOID_TYPE
+         && TREE_CODE (decl) != TREE_LIST)
+       {
+         /* Give various messages as the need arises.  */
+         if (TREE_CODE (decl) == STRING_CST)
+           cp_error ("invalid string constant `%E'", decl);
+         else if (TREE_CODE (decl) == INTEGER_CST)
+           error ("invalid integer constant in parameter list, did you forget to give parameter name?");
+         continue;
+       }
 
-             if (TREE_CODE (decl) == VOID_TYPE)
-               {
-                 if (result == NULL_TREE)
-                   {
-                     result = void_list_node;
-                     last_result = result;
-                   }
-                 else
-                   {
-                     TREE_CHAIN (last_result) = void_list_node;
-                     last_result = void_list_node;
-                   }
-                 if (chain
-                     && (chain != void_list_node || TREE_CHAIN (chain)))
-                   error ("`void' in parameter list must be entire list");
-                 break;
-               }
+      if (parm == void_list_node)
+        break;
 
-             /* Since there is a prototype, args are passed in their own types.  */
-             DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
-             if (PROMOTE_PROTOTYPES
-                 && (TREE_CODE (type) == INTEGER_TYPE
-                     || TREE_CODE (type) == ENUMERAL_TYPE)
-                 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
-               DECL_ARG_TYPE (decl) = integer_type_node;
-             if (!any_error && init)
-               {
-                 any_init++;
-                 init = check_default_argument (decl, init);
-               }
-             else
-               init = NULL_TREE;
+      decl = grokdeclarator (TREE_VALUE (decl), TREE_PURPOSE (decl),
+                            PARM, init != NULL_TREE, NULL_TREE);
+      if (! decl || TREE_TYPE (decl) == error_mark_node)
+        continue;
+    
+      type = TREE_TYPE (decl);
+      if (VOID_TYPE_P (type))
+        {
+          if (same_type_p (type, void_type_node)
+              && !DECL_NAME (decl) && !result && !chain && !ellipsis)
+            /* this is a parmlist of `(void)', which is ok.  */
+            break;
+          incomplete_type_error (decl, type);
+         /* It's not a good idea to actually create parameters of
+            type `void'; other parts of the compiler assume that a
+            void type terminates the parameter list.  */
+         type = error_mark_node;
+         TREE_TYPE (decl) = error_mark_node;
+        }
 
-             if (decls == NULL_TREE)
-               {
-                 decls = decl;
-                 last_decl = decls;
-               }
-             else
-               {
-                 TREE_CHAIN (last_decl) = decl;
-                 last_decl = decl;
-               }
-             list_node = tree_cons (init, type, NULL_TREE);
-             if (result == NULL_TREE)
-               {
-                 result = list_node;
-                 last_result = result;
-               }
-             else
-               {
-                 TREE_CHAIN (last_result) = list_node;
-                 last_result = list_node;
-               }
+      if (type != error_mark_node) 
+       {
+         /* Top-level qualifiers on the parameters are
+            ignored for function types.  */
+         type = TYPE_MAIN_VARIANT (type);
+         if (TREE_CODE (type) == METHOD_TYPE)
+           {
+             cp_error ("parameter `%D' invalidly declared method type", decl);
+             type = build_pointer_type (type);
+             TREE_TYPE (decl) = type;
            }
-         if (last_result)
-           TREE_CHAIN (last_result) = NULL_TREE;
-         /* If there are no parameters, and the function does not end
-            with `...', then last_decl will be NULL_TREE.  */
-         if (last_decl != NULL_TREE)
-           TREE_CHAIN (last_decl) = NULL_TREE;
+         else if (TREE_CODE (type) == OFFSET_TYPE)
+           {
+             cp_error ("parameter `%D' invalidly declared offset type", decl);
+             type = build_pointer_type (type);
+             TREE_TYPE (decl) = type;
+           }
+         else if (abstract_virtuals_error (decl, type))
+           any_error = 1;  /* Seems like a good idea. */
+         else if (POINTER_TYPE_P (type))
+           {
+             /* [dcl.fct]/6, parameter types cannot contain pointers
+                (references) to arrays of unknown bound.  */
+             tree t = type;
+
+             while (POINTER_TYPE_P (t)
+                    || (TREE_CODE (t) == ARRAY_TYPE
+                        && TYPE_DOMAIN (t) != NULL_TREE))
+               t = TREE_TYPE (t);
+             if (TREE_CODE (t) == ARRAY_TYPE)
+               cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
+                         decl, TYPE_PTR_P (type) ? "pointer" : "reference", t);
+           }
+
+         DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
+         if (PROMOTE_PROTOTYPES
+             && (TREE_CODE (type) == INTEGER_TYPE
+                 || TREE_CODE (type) == ENUMERAL_TYPE)
+             && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+           DECL_ARG_TYPE (decl) = integer_type_node;
+         if (!any_error && init)
+           init = check_default_argument (decl, init);
+         else
+           init = NULL_TREE;
        }
-    }
 
+      TREE_CHAIN (decl) = decls;
+      decls = decl;
+      result = tree_cons (init, type, result);
+    }
+  decls = nreverse (decls);
+  result = nreverse (result);
+  if (!ellipsis)
+    result = chainon (result, void_list_node);
   last_function_parms = decls;
 
   return result;
@@ -12237,9 +12135,7 @@ grok_ctor_properties (ctype, decl)
      other parameters have default arguments.  */
   if (TREE_CODE (parmtype) == REFERENCE_TYPE
       && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == ctype
-      && (TREE_CHAIN (parmtypes) == NULL_TREE
-         || TREE_CHAIN (parmtypes) == void_list_node
-         || TREE_PURPOSE (TREE_CHAIN (parmtypes)))
+      && sufficient_parms_p (TREE_CHAIN (parmtypes))
       && !(DECL_TEMPLATE_INSTANTIATION (decl)
           && is_member_template (DECL_TI_TEMPLATE (decl))))
     {
@@ -12263,9 +12159,7 @@ grok_ctor_properties (ctype, decl)
      existence.  Theoretically, they should never even be
      instantiated, but that's hard to forestall.  */
   else if (TYPE_MAIN_VARIANT (parmtype) == ctype
-          && (TREE_CHAIN (parmtypes) == NULL_TREE
-              || TREE_CHAIN (parmtypes) == void_list_node
-              || TREE_PURPOSE (TREE_CHAIN (parmtypes)))
+          && sufficient_parms_p (TREE_CHAIN (parmtypes))
           && !(DECL_TEMPLATE_INSTANTIATION (decl)
                && is_member_template (DECL_TI_TEMPLATE (decl))))
     {
@@ -12364,7 +12258,7 @@ grok_op_properties (decl, virtualp, friendp)
        case CALL_EXPR:
          TYPE_OVERLOADS_CALL_EXPR (current_class_type) = 1;
          break;
-         
+
        case ARRAY_REF:
          TYPE_OVERLOADS_ARRAY_REF (current_class_type) = 1;
          break;
@@ -12373,19 +12267,19 @@ grok_op_properties (decl, virtualp, friendp)
        case MEMBER_REF:
          TYPE_OVERLOADS_ARROW (current_class_type) = 1;
          break;
-         
+
        case NEW_EXPR:
          TYPE_HAS_NEW_OPERATOR (current_class_type) = 1;
          break;
-         
+
        case DELETE_EXPR:
          TYPE_GETS_DELETE (current_class_type) |= 1;
          break;
-         
+
        case VEC_NEW_EXPR:
          TYPE_HAS_ARRAY_NEW_OPERATOR (current_class_type) = 1;
          break;
-         
+
        case VEC_DELETE_EXPR:
          TYPE_GETS_DELETE (current_class_type) |= 2;
          break;
@@ -12402,27 +12296,14 @@ grok_op_properties (decl, virtualp, friendp)
       if (methodp)
        revert_static_member_fn (decl);
 
-      /* Take care of function decl if we had syntax errors.  */
-      if (argtypes == NULL_TREE)
-       TREE_TYPE (decl)
-         = build_function_type (ptr_type_node,
-                                hash_tree_chain (integer_type_node,
-                                                 void_list_node));
-      else
-       TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
+      TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
     }
   else if (operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR)
     {
       if (methodp)
        revert_static_member_fn (decl);
 
-      if (argtypes == NULL_TREE)
-       TREE_TYPE (decl)
-         = build_function_type (void_type_node,
-                                hash_tree_chain (ptr_type_node,
-                                                 void_list_node));
-      else
-       TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
+      TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
     }
   else
     {
@@ -12476,7 +12357,7 @@ grok_op_properties (decl, virtualp, friendp)
            {
              int ref = (TREE_CODE (t) == REFERENCE_TYPE);
              const char *what = 0;
-             
+
              if (ref)
                t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
 
@@ -12496,7 +12377,7 @@ grok_op_properties (decl, virtualp, friendp)
            }
        }
 
-      if (DECL_ASSIGNMENT_OPERATOR_P (decl) 
+      if (DECL_ASSIGNMENT_OPERATOR_P (decl)
          && operator_code == NOP_EXPR)
        {
          tree parmtype;
@@ -12761,6 +12642,22 @@ xref_tag (code_type_node, name, globalize)
   else
     t = IDENTIFIER_TYPE_VALUE (name);
 
+  /* Warn about 'friend struct Inherited;' doing the wrong thing.  */
+  if (t && globalize && TREE_CODE (t) == TYPENAME_TYPE)
+    {
+      static int explained;
+
+      cp_warning ("`%s %T' declares a new type at namespace scope;\n\
+to refer to the inherited type, say `%s %T::%T'%s",
+                 tag_name (tag_code), name, tag_name (tag_code),
+                 constructor_name (current_class_type), TYPE_IDENTIFIER (t),
+                 (!explained ? "\n\
+(names from dependent base classes are not visible to unqualified name lookup)"
+                  : ""));
+
+      explained = 1;
+    }
+
   if (t && TREE_CODE (t) != code && TREE_CODE (t) != TEMPLATE_TYPE_PARM
       && TREE_CODE (t) != BOUND_TEMPLATE_TEMPLATE_PARM)
     t = NULL_TREE;
@@ -13080,9 +12977,9 @@ xref_basetypes (code_type_node, name, ref, binfo)
 
          if (CLASS_TYPE_P (basetype))
            {
-             TYPE_HAS_NEW_OPERATOR (ref) 
+             TYPE_HAS_NEW_OPERATOR (ref)
                |= TYPE_HAS_NEW_OPERATOR (basetype);
-             TYPE_HAS_ARRAY_NEW_OPERATOR (ref) 
+             TYPE_HAS_ARRAY_NEW_OPERATOR (ref)
                |= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype);
              TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
              /* If the base-class uses multiple inheritance, so do we.  */
@@ -13244,7 +13141,7 @@ finish_enum (enumtype)
     {
       tree scope = current_scope ();
       if (scope && TREE_CODE (scope) == FUNCTION_DECL)
-       add_tree (build_min (TAG_DEFN, enumtype));
+       add_stmt (build_min (TAG_DEFN, enumtype));
     }
   else
     {
@@ -13398,7 +13295,7 @@ build_enumerator (name, value, enumtype)
 
   if (context && context == current_class_type)
     /* This enum declaration is local to the class.  We need the full
-      lang_decl so that we can record DECL_CLASS_CONTEXT, for example.  */
+       lang_decl so that we can record DECL_CLASS_CONTEXT, for example.  */
     decl = build_lang_decl (CONST_DECL, name, type);
   else
     /* It's a global enum, or it's local to a function.  (Note local to
@@ -13428,8 +13325,9 @@ build_enumerator (name, value, enumtype)
 /* We're defining DECL.  Make sure that it's type is OK.  */
 
 static void
-check_function_type (decl)
+check_function_type (decl, current_function_parms)
      tree decl;
+     tree current_function_parms;
 {
   tree fntype = TREE_TYPE (decl);
   tree return_type = complete_type (TREE_TYPE (fntype));
@@ -13471,9 +13369,7 @@ check_function_type (decl)
    FLAGS is a bitwise or of SF_PRE_PARSED (indicating that the
    DECLARATOR is really the DECL for the function we are about to
    process and that DECLSPECS should be ignored), SF_INCLASS_INLINE
-   indicating that the function is an inline defined in-class, and
-   SF_EXPAND indicating that we should generate RTL for this
-   function.
+   indicating that the function is an inline defined in-class.
 
    This function creates a binding context for the function body
    as well as setting up the FUNCTION_DECL in current_function_decl.
@@ -13500,6 +13396,7 @@ start_function (declspecs, declarator, attrs, flags)
   extern int used_extern_spec;
   int doing_friend = 0;
   struct binding_level *bl;
+  tree current_function_parms;
 
   /* Sanity check.  */
   my_friendly_assert (TREE_CODE (TREE_VALUE (void_list_node)) == VOID_TYPE, 160);
@@ -13508,7 +13405,7 @@ start_function (declspecs, declarator, attrs, flags)
   /* This should only be done once on the top most decl.  */
   if (have_extern_spec && !used_extern_spec)
     {
-      declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
+      declspecs = tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
       used_extern_spec = 1;
     }
 
@@ -13609,7 +13506,7 @@ start_function (declspecs, declarator, attrs, flags)
   if (flags & SF_INCLASS_INLINE)
     maybe_begin_member_template_processing (decl1);
 
-  /* Effective C++ rule 15.  See also c_expand_return.  */
+  /* Effective C++ rule 15.  */
   if (warn_ecpp
       && DECL_OVERLOADED_OPERATOR_P (decl1) == NOP_EXPR
       && TREE_CODE (TREE_TYPE (fntype)) == VOID_TYPE)
@@ -13647,7 +13544,7 @@ start_function (declspecs, declarator, attrs, flags)
      you declare a function, these types can be incomplete, but they
      must be complete when you define the function.  */
   if (! processing_template_decl)
-    check_function_type (decl1);
+    check_function_type (decl1, current_function_parms);
 
   /* Build the return declaration for the function.  */
   restype = TREE_TYPE (fntype);
@@ -13668,11 +13565,11 @@ start_function (declspecs, declarator, attrs, flags)
   /* Initialize RTL machinery.  We cannot do this until
      CURRENT_FUNCTION_DECL and DECL_RESULT are set up.  We do this
      even when processing a template; this is how we get
-     CFUN set up, and our per-function variables initialized.  */
+     CFUN set up, and our per-function variables initialized.
+     FIXME factor out the non-RTL stuff.  */
   bl = current_binding_level;
   init_function_start (decl1, input_filename, lineno);
   current_binding_level = bl;
-  expanding_p = (flags & SF_EXPAND) != 0;
 
   /* Even though we're inside a function body, we still don't want to
      call expand_expr to calculate the size of a variable-sized array.
@@ -13681,9 +13578,8 @@ start_function (declspecs, declarator, attrs, flags)
   immediate_size_expand = 0;
   cfun->x_dont_save_pending_sizes_p = 1;
 
-  /* If we're building a statement-tree, start the tree now.  */
-  if (processing_template_decl || !expanding_p)
-    begin_stmt_tree (&DECL_SAVED_TREE (decl1));
+  /* Start the statement-tree, start the tree now.  */
+  begin_stmt_tree (&DECL_SAVED_TREE (decl1));
 
   /* Let the user know we're compiling this function.  */
   announce_function (decl1);
@@ -13712,29 +13608,16 @@ start_function (declspecs, declarator, attrs, flags)
   current_function_decl = decl1;
   cfun->decl = decl1;
 
-  /* Initialize the per-function data.  */
-  if (!DECL_PENDING_INLINE_P (decl1) && DECL_SAVED_FUNCTION_DATA (decl1))
+  /* If we are (erroneously) defining a function that we have already
+     defined before, wipe out what we knew before.  */
+  if (!DECL_PENDING_INLINE_P (decl1)
+      && DECL_SAVED_FUNCTION_DATA (decl1))
     {
-      /* If we already parsed this function, and we're just expanding it
-        now, restore saved state.  */
-      struct binding_level *bl = current_binding_level;
-      *cp_function_chain = *DECL_SAVED_FUNCTION_DATA (decl1);
-      current_binding_level = bl;
-
-      /* This function is being processed in whole-function mode; we
-        already did semantic analysis.  */
-      cfun->x_whole_function_mode_p = 1;
-
-      /* If we decided that we didn't want to inline this function,
-        make sure the back-end knows that.  */
-      if (!current_function_cannot_inline)
-       current_function_cannot_inline = cp_function_chain->cannot_inline;
-
-      /* We don't need the saved data anymore.  */
       free (DECL_SAVED_FUNCTION_DATA (decl1));
       DECL_SAVED_FUNCTION_DATA (decl1) = NULL;
     }
-  else if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1))
+
+  if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1))
     {
       /* We know that this was set up by `grokclassfn'.  We do not
         wait until `store_parm_decls', since evil parse errors may
@@ -13822,18 +13705,12 @@ start_function (declspecs, declarator, attrs, flags)
        DECL_INTERFACE_KNOWN (decl1) = 1;
     }
 
-  if (doing_semantic_analysis_p ())
-    {
-      pushlevel (0);
-      current_binding_level->parm_flag = 1;
-    }
+  pushlevel (0);
+  current_binding_level->parm_flag = 1;
 
   if (attrs)
     cplus_decl_attributes (decl1, NULL_TREE, attrs);
 
-  if (!building_stmt_tree ())
-    GNU_xref_function (decl1, current_function_parms);
-
   /* We need to do this even if we aren't expanding yet so that
      assemble_external works.  */
   make_function_rtl (decl1);
@@ -13873,25 +13750,20 @@ start_function (declspecs, declarator, attrs, flags)
       DECL_CONTEXT (ctor_label) = current_function_decl;
     }
 
+  store_parm_decls (current_function_parms);
+
   return 1;
 }
 \f
-/* Called after store_parm_decls for a function-try-block.  */
-
-void
-expand_start_early_try_stmts ()
-{
-  expand_start_try_stmts ();
-}
-
 /* Store the parameter declarations into the current function declaration.
    This is called after parsing the parameter declarations, before
    digesting the body of the function.
 
    Also install to binding contour return value identifier, if any.  */
 
-void
-store_parm_decls ()
+static void
+store_parm_decls (current_function_parms)
+     tree current_function_parms;
 {
   register tree fndecl = current_function_decl;
   register tree parm;
@@ -13906,10 +13778,6 @@ store_parm_decls ()
      then CONST_DECLs for foo and bar are put here.  */
   tree nonparms = NULL_TREE;
 
-  /* Create a binding level for the parms.  */
-  if (!building_stmt_tree ())
-    expand_start_bindings (2);
-
   if (current_function_parms)
     {
       /* This case is when the function was defined with an ANSI prototype.
@@ -13920,45 +13788,34 @@ store_parm_decls ()
       tree specparms = current_function_parms;
       tree next;
 
-      if (doing_semantic_analysis_p ())
-       {
-         /* Must clear this because it might contain TYPE_DECLs declared
+      /* Must clear this because it might contain TYPE_DECLs declared
             at class level.  */
-         storedecls (NULL_TREE);
+      storedecls (NULL_TREE);
 
-         /* If we're doing semantic analysis, then we'll call pushdecl
+      /* If we're doing semantic analysis, then we'll call pushdecl
             for each of these.  We must do them in reverse order so that
             they end in the correct forward order.  */
-         specparms = nreverse (specparms);
-       }
+      specparms = nreverse (specparms);
 
       for (parm = specparms; parm; parm = next)
        {
          next = TREE_CHAIN (parm);
          if (TREE_CODE (parm) == PARM_DECL)
            {
-             tree type = TREE_TYPE (parm);
+             tree cleanup;
 
-             if (doing_semantic_analysis_p ())
-               {
-                 tree cleanup;
-
-                 if (DECL_NAME (parm) == NULL_TREE
-                     || TREE_CODE (parm) != VOID_TYPE)
-                   pushdecl (parm);
-                 else
-                   cp_error ("parameter `%D' declared void", parm);
+             if (DECL_NAME (parm) == NULL_TREE
+                 || TREE_CODE (parm) != VOID_TYPE)
+               pushdecl (parm);
+             else
+               cp_error ("parameter `%D' declared void", parm);
 
-                 cleanup = (processing_template_decl 
-                            ? NULL_TREE
-                            : maybe_build_cleanup (parm));
+             cleanup = (processing_template_decl
+                        ? NULL_TREE
+                        : maybe_build_cleanup (parm));
 
-                 if (cleanup)
-                   cleanups = tree_cons (parm, cleanup, cleanups);
-               }
-             else if (type != error_mark_node
-                      && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
-               parms_have_cleanups = 1;
+             if (cleanup)
+               cleanups = tree_cons (parm, cleanup, cleanups);
            }
          else
            {
@@ -13969,14 +13826,11 @@ store_parm_decls ()
            }
        }
 
-      if (doing_semantic_analysis_p ())
-       {
-         /* Get the decls in their original chain order
-            and record in the function.  This is all and only the
-            PARM_DECLs that were pushed into scope by the loop above.  */
-         DECL_ARGUMENTS (fndecl) = getdecls ();
-         storetags (chainon (parmtags, gettags ()));
-       }
+      /* Get the decls in their original chain order and record in the
+        function.  This is all and only the PARM_DECLs that were
+        pushed into scope by the loop above.  */
+      DECL_ARGUMENTS (fndecl) = getdecls ();
+      storetags (chainon (parmtags, gettags ()));
     }
   else
     DECL_ARGUMENTS (fndecl) = NULL_TREE;
@@ -13985,20 +13839,7 @@ store_parm_decls ()
      as the decl-chain of the current lexical scope.
      Put the enumerators in as well, at the front so that
      DECL_ARGUMENTS is not modified.  */
-  if (doing_semantic_analysis_p ())
-    storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
-
-  /* Initialize the RTL code for the function.  */
-  DECL_SAVED_INSNS (fndecl) = 0;
-  if (! building_stmt_tree ())
-    expand_function_start (fndecl, parms_have_cleanups);
-
-  current_function_parms_stored = 1;
-
-  /* If this function is `main', emit a call to `__main'
-     to run global initializers, etc.  */
-  if (DECL_MAIN_P (fndecl) && !building_stmt_tree ())
-    expand_main_function ();
+  storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
 
   /* Now that we have initialized the parms, we can start their
      cleanups.  We cannot do this before, since expand_decl_cleanup
@@ -14011,19 +13852,13 @@ store_parm_decls ()
     }
 
   /* Create a binding contour which can be used to catch
-     cleanup-generated temporaries.  Also, if the return value needs or
-     has initialization, deal with that now.  */
+     cleanup-generated temporaries.  */
   if (parms_have_cleanups)
-    {
-      pushlevel (0);
-      if (!building_stmt_tree ())
-       expand_start_bindings (2);
-    }
+    pushlevel (0);
 
   /* Do the starting of the exception specifications, if we have any.  */
   if (flag_exceptions && !processing_template_decl
       && flag_enforce_eh_specs
-      && building_stmt_tree ()
       && TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)))
     current_eh_spec_try_block = expand_start_eh_spec ();
 }
@@ -14037,7 +13872,7 @@ static void
 save_function_data (decl)
      tree decl;
 {
-  struct language_function *f;
+  struct cp_language_function *f;
 
   /* Save the language-specific per-function data so that we can
      get it back when we really expand this function.  */
@@ -14045,16 +13880,14 @@ save_function_data (decl)
                      19990908);
 
   /* Make a copy.  */
-  f = ((struct language_function *)
-       xmalloc (sizeof (struct language_function)));
-  bcopy ((char *) cp_function_chain, (char *) f,
-        sizeof (struct language_function));
+  f = ((struct cp_language_function *)
+       xmalloc (sizeof (struct cp_language_function)));
+  memcpy (f, cp_function_chain, sizeof (struct cp_language_function));
   DECL_SAVED_FUNCTION_DATA (decl) = f;
 
   /* Clear out the bits we don't need.  */
-  f->x_stmt_tree.x_last_stmt = NULL_TREE;
-  f->x_stmt_tree.x_last_expr_type = NULL_TREE;
-  f->x_result_rtx = NULL_RTX;
+  f->base.x_stmt_tree.x_last_stmt = NULL_TREE;
+  f->base.x_stmt_tree.x_last_expr_type = NULL_TREE;
   f->x_named_label_uses = NULL;
   f->bindings = NULL;
 
@@ -14075,7 +13908,7 @@ finish_constructor_body ()
 {
   /* Any return from a constructor will end up here.  */
   if (ctor_label)
-    add_tree (build_stmt (LABEL_STMT, ctor_label));
+    add_stmt (build_stmt (LABEL_STMT, ctor_label));
 
   /* Clear CTOR_LABEL so that finish_return_stmt knows to really
      generate the return, rather than a goto to CTOR_LABEL.  */
@@ -14084,7 +13917,7 @@ finish_constructor_body ()
      constructor to a return of `this'.  */
   finish_return_stmt (NULL_TREE);
   /* Mark the end of the constructor.  */
-  add_tree (build_stmt (CTOR_STMT));
+  add_stmt (build_stmt (CTOR_STMT));
 }
 
 /* At the end of every destructor we generate code to restore virtual
@@ -14103,7 +13936,7 @@ finish_destructor_body ()
   compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
 
   /* Any return from a destructor will end up here.  */
-  add_tree (build_stmt (LABEL_STMT, dtor_label));
+  add_stmt (build_stmt (LABEL_STMT, dtor_label));
 
   /* Generate the code to call destructor on base class.  If this
      destructor belongs to a class with virtual functions, then set
@@ -14219,13 +14052,9 @@ finish_function (flags)
 {
   register tree fndecl = current_function_decl;
   tree fntype, ctype = NULL_TREE;
-  /* Label to use if this function is supposed to return a value.  */
-  tree no_return_label = NULL_TREE;
   int call_poplevel = (flags & 1) != 0;
   int inclass_inline = (flags & 2) != 0;
-  int expand_p;
   int nested;
-  int current_line = lineno;
 
   /* When we get some parse errors, we can end up without a
      current_function_decl, so cope.  */
@@ -14239,18 +14068,11 @@ finish_function (flags)
       This caused &foo to be of type ptr-to-const-function
       which then got a warning when stored in a ptr-to-function variable.  */
 
-  /* This happens on strange parse errors.  */
-  if (! current_function_parms_stored)
-    {
-      call_poplevel = 0;
-      store_parm_decls ();
-    }
+  my_friendly_assert (building_stmt_tree (), 20000911);
 
   /* For a cloned function, we've already got all the code we need;
      there's no need to add any extra bits.  */
-  if (building_stmt_tree () && DECL_CLONED_FUNCTION_P (fndecl))
-    ;
-  else if (building_stmt_tree ())
+  if (!DECL_CLONED_FUNCTION_P (fndecl))
     {
       if (DECL_CONSTRUCTOR_P (fndecl))
        {
@@ -14278,132 +14100,16 @@ finish_function (flags)
                            (TREE_TYPE (current_function_decl)),
                            current_eh_spec_try_block);
     }
-  else
-    {
-#if 0
-      if (write_symbols != NO_DEBUG /*&& TREE_CODE (fntype) != METHOD_TYPE*/)
-       {
-         /* Keep this code around in case we later want to control debug info
-            based on whether a type is "used".  (jason 1999-11-11) */
-
-         tree ttype = target_type (fntype);
-         tree parmdecl;
-
-         if (IS_AGGR_TYPE (ttype))
-           /* Let debugger know it should output info for this type.  */
-           note_debug_info_needed (ttype);
-
-         for (parmdecl = DECL_ARGUMENTS (fndecl); parmdecl; parmdecl = TREE_CHAIN (parmdecl))
-           {
-             ttype = target_type (TREE_TYPE (parmdecl));
-             if (IS_AGGR_TYPE (ttype))
-               /* Let debugger know it should output info for this type.  */
-               note_debug_info_needed (ttype);
-           }
-       }
-#endif
-
-      /* Clean house because we will need to reorder insns here.  */
-      do_pending_stack_adjust ();
-
-      if (dtor_label)
-       ;
-      else if (DECL_CONSTRUCTOR_P (fndecl))
-       {
-         if (call_poplevel)
-           do_poplevel ();
-       }
-      else if (return_label != NULL_RTX
-              && flag_this_is_variable <= 0
-              && current_function_return_value == NULL_TREE
-              && ! DECL_NAME (DECL_RESULT (current_function_decl)))
-       no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
-
-      if (flag_exceptions)
-       expand_exception_blocks ();
-
-      /* If this function is supposed to return a value, ensure that
-        we do not fall into the cleanups by mistake.  The end of our
-        function will look like this:
-
-        user code (may have return stmt somewhere)
-        goto no_return_label
-        cleanup_label:
-        cleanups
-        goto return_label
-        no_return_label:
-        NOTE_INSN_FUNCTION_END
-        return_label:
-        things for return
-
-        If the user omits a return stmt in the USER CODE section, we
-        will have a control path which reaches NOTE_INSN_FUNCTION_END.
-        Otherwise, we won't.  */
-      if (no_return_label)
-       {
-         DECL_CONTEXT (no_return_label) = fndecl;
-         DECL_INITIAL (no_return_label) = error_mark_node;
-         DECL_SOURCE_FILE (no_return_label) = input_filename;
-         DECL_SOURCE_LINE (no_return_label) = current_line;
-         expand_goto (no_return_label);
-       }
-
-      if (cleanup_label)
-       {
-         /* Remove the binding contour which is used
-            to catch cleanup-generated temporaries.  */
-         expand_end_bindings (0, 0, 0);
-         poplevel (0, 0, 0);
-
-         /* Emit label at beginning of cleanup code for parameters.  */
-         emit_label (cleanup_label);
-       }
-
-      /* Get return value into register if that's where it's supposed
-        to be.  */
-      if (original_result_rtx)
-       fixup_result_decl (DECL_RESULT (fndecl), original_result_rtx);
-
-      /* Finish building code that will trigger warnings if users forget
-        to make their functions return values.  */
-      if (no_return_label || cleanup_label)
-       emit_jump (return_label);
-      if (no_return_label)
-       {
-         /* We don't need to call `expand_*_return' here because we
-            don't need any cleanups here--this path of code is only
-            for error checking purposes.  */
-         expand_label (no_return_label);
-       }
-
-      /* We hard-wired immediate_size_expand to zero in
-        start_function.  Expand_function_end will decrement this
-        variable.  So, we set the variable to one here, so that after
-        the decrement it will remain zero.  */
-      immediate_size_expand = 1;
-
-      /* Generate rtl for function exit.  */
-      expand_function_end (input_filename, current_line, 1);
-    }
-
-  /* We have to save this value here in case
-     maybe_end_member_template_processing decides to pop all the
-     template parameters.  */
-  expand_p = !building_stmt_tree ();
 
   /* If we're saving up tree structure, tie off the function now.  */
-  if (!expand_p)
-    finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
+  finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
 
   /* This must come after expand_function_end because cleanups might
      have declarations (from inline functions) that need to go into
      this function's blocks.  */
-  if (doing_semantic_analysis_p ())
-    {
-      if (current_binding_level->parm_flag != 1)
-       my_friendly_abort (122);
-      poplevel (1, 0, 1);
-    }
+  if (current_binding_level->parm_flag != 1)
+    my_friendly_abort (122);
+  poplevel (1, 0, 1);
 
   /* Remember that we were in class scope.  */
   if (current_class_name)
@@ -14417,7 +14123,7 @@ finish_function (flags)
   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
 
   /* Save away current state, if appropriate.  */
-  if (!expanding_p && !processing_template_decl)
+  if (!processing_template_decl)
     save_function_data (fndecl);
 
   /* If this function calls `setjmp' it cannot be inlined.  When
@@ -14429,96 +14135,15 @@ finish_function (flags)
      this function to modify local variables in `c', but their
      addresses may have been stored somewhere accessible to this
      function.)  */
-  if (!expanding_p && !processing_template_decl && calls_setjmp_p (fndecl))
+  if (!processing_template_decl && calls_setjmp_p (fndecl))
     DECL_UNINLINABLE (fndecl) = 1;
 
-  if (expand_p)
-    {
-      int returns_null;
-      int returns_value;
-
-      /* So we can tell if jump_optimize sets it to 1.  */
-      can_reach_end = 0;
-
-      /* Before we call rest_of_compilation (which will pop the
-        CURRENT_FUNCTION), we must save these values.  */
-      returns_null = current_function_returns_null;
-      returns_value = current_function_returns_value;
-
-      /* If this is a nested function (like a template instantiation
-        that we're compiling in the midst of compiling something
-        else), push a new GC context.  That will keep local variables
-        on the stack from being collected while we're doing the
-        compilation of this function.  */
-      if (function_depth > 1)
-       ggc_push_context ();
-
-      /* Run the optimizers and output the assembler code for this
-         function.  */
-      rest_of_compilation (fndecl);
-
-      /* Undo the call to ggc_push_context above.  */
-      if (function_depth > 1)
-       ggc_pop_context ();
-
-      if (DECL_SAVED_INSNS (fndecl) && ! TREE_ASM_WRITTEN (fndecl))
-       {
-         /* Set DECL_EXTERNAL so that assemble_external will be called as
-            necessary.  We'll clear it again in finish_file.  */
-         if (! DECL_EXTERNAL (fndecl))
-           DECL_NOT_REALLY_EXTERN (fndecl) = 1;
-         DECL_EXTERNAL (fndecl) = 1;
-         defer_fn (fndecl);
-       }
-
-#if 0
-      /* Keep this code around in case we later want to control debug info
-        based on whether a type is "used".  (jason 1999-11-11) */
-
-      if (ctype && TREE_ASM_WRITTEN (fndecl))
-       note_debug_info_needed (ctype);
-#endif
-
-      /* If this function is marked with the constructor attribute,
-        add it to the list of functions to be called along with
-        constructors from static duration objects.  */
-      if (DECL_STATIC_CONSTRUCTOR (fndecl))
-       static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
-
-      /* If this function is marked with the destructor attribute,
-        add it to the list of functions to be called along with
-        destructors from static duration objects.  */
-      if (DECL_STATIC_DESTRUCTOR (fndecl))
-       static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
-
-      if (DECL_NAME (DECL_RESULT (fndecl)))
-       returns_value |= can_reach_end;
-      else
-       returns_null |= can_reach_end;
-
-      if (TREE_THIS_VOLATILE (fndecl) && returns_null)
-       warning ("`noreturn' function does return");
-      else if (returns_null
-              && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE)
-       {
-         /* Always complain if there's just no return statement.  */
-         if (!returns_value)
-           warning ("no return statement in function returning non-void");
-         else if (warn_return_type || pedantic)
-           /* If this function returns non-void and control can drop through,
-              complain.  */
-           warning ("control reaches end of non-void function");
-       }
-    }
-  else
-    {
-      /* Clear out memory we no longer need.  */
-      free_after_parsing (cfun);
-      /* Since we never call rest_of_compilation, we never clear
-        CFUN.  Do so explicitly.  */
-      free_after_compilation (cfun);
-      cfun = NULL;
-    }
+  /* Clear out memory we no longer need.  */
+  free_after_parsing (cfun);
+  /* Since we never call rest_of_compilation, we never clear
+     CFUN.  Do so explicitly.  */
+  free_after_compilation (cfun);
+  cfun = NULL;
 
   /* If this is a in-class inline definition, we may have to pop the
      bindings for the template parameters that we added in
@@ -14533,30 +14158,12 @@ finish_function (flags)
 
   --function_depth;
 
-  if (!DECL_SAVED_INSNS (fndecl) && !DECL_SAVED_FUNCTION_DATA (fndecl)
-      && !(flag_inline_trees && DECL_INLINE (fndecl)))
-    {
-      tree t;
-
-      /* Stop pointing to the local nodes about to be freed.  */
-      /* But DECL_INITIAL must remain nonzero so we know this
-        was an actual function definition.  */
-      DECL_INITIAL (fndecl) = error_mark_node;
-      for (t = DECL_ARGUMENTS (fndecl); t; t = TREE_CHAIN (t))
-       DECL_RTL (t) = DECL_INCOMING_RTL (t) = NULL_RTX;
-    }
-
   /* Clean up.  */
   if (! nested)
-    {
-      /* Let the error reporting routines know that we're outside a
-         function.  For a nested function, this value is used in
-         pop_cp_function_context and then reset via pop_function_context.  */
-      current_function_decl = NULL_TREE;
-      /* We don't really care about obstacks, but the middle-end
-        sometimes cares on what obstck things are located.  */
-      permanent_allocation (1);
-    }
+    /* Let the error reporting routines know that we're outside a
+       function.  For a nested function, this value is used in
+       pop_cp_function_context and then reset via pop_function_context.  */
+    current_function_decl = NULL_TREE;
 
   return fndecl;
 }
@@ -14826,31 +14433,6 @@ maybe_build_cleanup (decl)
   return 0;
 }
 \f
-/* Expand a C++ expression at the statement level.
-   This is needed to ferret out nodes which have UNKNOWN_TYPE.
-   The C++ type checker should get all of these out when
-   expressions are combined with other, type-providing, expressions,
-   leaving only orphan expressions, such as:
-
-   &class::bar;                / / takes its address, but does nothing with it.  */
-
-void
-cplus_expand_expr_stmt (exp)
-     tree exp;
-{
-#if 0
-  /* We should do this eventually, but right now this causes regex.o from
-     libg++ to miscompile, and tString to core dump.  */
-  exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp);
-#endif
-
-  /* If we don't do this, we end up down inside expand_expr
-     trying to do TYPE_MODE on the ERROR_MARK, and really
-     go outside the bounds of the type.  */
-  if (exp != error_mark_node)
-    expand_expr_stmt (exp);
-}
-
 /* When a stmt has been parsed, this function is called.  */
 
 void
@@ -14876,7 +14458,7 @@ revert_static_member_fn (decl)
   if (CP_TYPE_QUALS (TREE_TYPE (TREE_VALUE (args)))
       != TYPE_UNQUALIFIED)
     cp_error ("static member function `%#D' declared with type qualifiers",
-             *decl);
+             decl);
 
   args = TREE_CHAIN (args);
   tmp = build_function_type (TREE_TYPE (function), args);
@@ -14896,10 +14478,10 @@ static void
 push_cp_function_context (f)
      struct function *f;
 {
-  struct language_function *p
-    = ((struct language_function *)
-       xcalloc (1, sizeof (struct language_function)));
-  f->language = p;
+  struct cp_language_function *p
+    = ((struct cp_language_function *)
+       xcalloc (1, sizeof (struct cp_language_function)));
+  f->language = (struct language_function *) p;
 
   /* It takes an explicit call to expand_body to generate RTL for a
      function.  */
@@ -14907,7 +14489,7 @@ push_cp_function_context (f)
 
   /* Whenever we start a new function, we destroy temporaries in the
      usual way.  */
-  current_stmt_tree->stmts_are_full_exprs_p = 1;
+  current_stmt_tree ()->stmts_are_full_exprs_p = 1;
 }
 
 /* Free the language-specific parts of F, now that we've finished
@@ -14926,22 +14508,20 @@ pop_cp_function_context (f)
 
 static void
 mark_lang_function (p)
-     struct language_function *p;
+     struct cp_language_function *p;
 {
   if (!p)
     return;
 
+  mark_c_language_function (&p->base);
+
   ggc_mark_tree (p->x_ctor_label);
   ggc_mark_tree (p->x_dtor_label);
   ggc_mark_tree (p->x_current_class_ptr);
   ggc_mark_tree (p->x_current_class_ref);
   ggc_mark_tree (p->x_eh_spec_try_block);
-  ggc_mark_tree (p->x_scope_stmt_stack);
-
-  ggc_mark_rtx (p->x_result_rtx);
 
   mark_named_label_lists (&p->x_named_labels, &p->x_named_label_uses);
-  mark_stmt_tree (&p->x_stmt_tree);
   mark_binding_level (&p->bindings);
 }
 
@@ -14951,15 +14531,7 @@ static void
 mark_cp_function_context (f)
      struct function *f;
 {
-  mark_lang_function (f->language);
-}
-
-void
-lang_mark_false_label_stack (l)
-     struct label_node *l;
-{
-  /* C++ doesn't use false_label_stack.  It better be NULL.  */
-  my_friendly_assert (l == NULL, 19990904);
+  mark_lang_function ((struct cp_language_function *) f->language);
 }
 
 void
@@ -15002,13 +14574,13 @@ lang_mark_tree (t)
       if (ld)
        {
          ggc_mark (ld);
-         if (!DECL_GLOBAL_CTOR_P (t) 
+         c_mark_lang_decl (&ld->decl_flags.base);
+         if (!DECL_GLOBAL_CTOR_P (t)
              && !DECL_GLOBAL_DTOR_P (t)
              && !DECL_THUNK_P (t))
            ggc_mark_tree (ld->decl_flags.u2.access);
          else if (DECL_THUNK_P (t))
            ggc_mark_tree (ld->decl_flags.u2.vcall_offset);
-         ggc_mark_tree (ld->decl_flags.context);
          if (TREE_CODE (t) != NAMESPACE_DECL)
            ggc_mark_tree (ld->decl_flags.u.template_info);
          else
@@ -15016,7 +14588,7 @@ lang_mark_tree (t)
          if (CAN_HAVE_FULL_LANG_DECL_P (t))
            {
              ggc_mark_tree (ld->befriending_classes);
-             ggc_mark_tree (ld->saved_tree);
+             ggc_mark_tree (ld->context);
              ggc_mark_tree (ld->cloned_function);
              if (!DECL_OVERLOADED_OPERATOR_P (t))
                ggc_mark_tree (ld->u2.vtt_parm);
@@ -15054,3 +14626,13 @@ lang_mark_tree (t)
        ggc_mark_tree ((tree) lt);
     }
 }
+
+/* Return the IDENTIFIER_GLOBAL_VALUE of T, for use in common code, since
+   the definition of IDENTIFIER_GLOBAL_VALUE is different for C and C++.  */
+
+tree
+identifier_global_value        (t)
+     tree t;
+{
+  return IDENTIFIER_GLOBAL_VALUE (t);
+}