OSDN Git Service

Make DECL_CONTEXT mean the class in which a member function was
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Feb 2000 23:54:23 +0000 (23:54 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Feb 2000 23:54:23 +0000 (23:54 +0000)
declared, even for a virtual function.
* cp-tree.h (DECL_CLASS_CONTEXT): Adjust.
(DECL_FRIEND_CONTEXT): New macro.
(DECL_REAL_CONTEXT): Remove.
(SET_DECL_FRIEND_CONTEXT): Likewise.
(DECL_VIRTUAL_CONTEXT): Adjust.
(DECL_CLASS_SCOPE_P): Use TYPE_P.
(add_friends): Remove.
(hack_decl_function_context): Likewise.
* call.c (build_new_function_call): Replace DECL_REAL_CONTEXT with
CP_DECL_CONTEXT.
(build_over_call): Fix indentation.  Use DECL_CONTEXT
instead of DECL_CLASS_CONTEXT.
* class.c (dfs_build_vcall_offset_vtbl_entries): Likewise.
(add_method): Set DECL_VIRTUAL_CONTEXT, not DECL_CLASS_CONTEXT.
(strictly_overrides): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
(build_vtbl_or_vbase_field): Don't set DECL_CLASS_CONTEXT.
(build_base_field): Likewise.
(finish_struct_1): Likewise.
(build_self_reference): Likewise.
* decl.c (push_class_binding): Use CP_DECL_CONTEXT, not
DECL_REAL_CONTEXT.
(pushtag): Use decl_function_context, not
hack_decl_function_context.
(decls_match): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
(duplicate_decls): Use DECL_VIRTUAL_CONTEXT.
(pushdecl): Remove bogus code.
(start_decl): Use DECL_CONTEXT rather than DECL_CLASS_CONTEXT.
(cp_finish_decl): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
(grokfndecl): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
Use decl_function_context, nothack_decl_function_context.
(grokvardecl): Don't set DECL_CLASS_CONTEXT.
(grokdeclarator): Likewise.  Use decl_function_context, not
hack_decl_function_context.
(copy_args_p): Document.  Don't use DECL_CLASS_CONTEXT.
(start_function): Use DECL_FRIEND_CONTEXT, not
DECL_CLASS_CONTEXT.  Use decl_function_context, not
hack_decl_function_context.
(finish_function): Use decl_function_context, not
hack_decl_function_context.
(maybe_retrofit_in_chrg): Use DECL_CONTEXT, not
DECL_CLASS_CONTEXT.
(grokclassfn): Set DECL_VIRTUAL_CONTEXT, not DECL_CONTEXT.
(finish_static_data_member_decl): Don't set DECL_CLASS_CONTEXT.
(grokfield): Likewise.
(finish_builtin_type): Likewise.
(finish_vtable_vardec): Use decl_function_context, not
hack_decl_function_context.
(import_export_decl): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
(start_static_initialization_or_destruction): Likewise.
(finish_static_initialization_or_destruction): Likewise.
(mark_used): Adjust logic for deciding when to synthesize methods.
* dump.c (dequeue_and_dump): Use CP_DECL_CONTEXT, not
DECL_REAL_CONTEXT.
* error.c (dump_function_decl): Use DECL_CONTEXT, not
DECL_CLASS_CONTEXT.
* friend.c (is_friend): Likewise.
(add_friends): Remove.
(do_friend): Use SET_DECL_FRIEND_CONTEXT.
* lex.c (begin_definition_of_inclass_inline): Use
decl_function_context, not hack_decl_function_context.
(process_next_inline): Likewise.
(do_identifier): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
* method.c (set_mangled_name_for_decl): Use DECL_CONTEXT, not
DECL_CLASSS_CONTEXT.
(hack_identifier): Likewise.
(synthesize_method):  Use decl_function_context, not
hack_decl_function_context.
* pt.c (template_class_depth_real): Use CP_DECL_CONTEXT, not
DECL_REAL_CONTEXT.
(is_member_template): Use decl_function_context, not
hack_decl_function_context.  Use DECL_CONTEXT, not
DECL_CLASS_CONTEXT.
(build_template_decl): Set DECL_VIRTUAL_CONTEXT, not
DECL_CLASS_CONTEXT.
(check_default_tmpl_args): Use CP_DECL_CONTEXT, not
DECL_REAL_CONTEXT.
(push_template_decl_real): Likewise.
(instantiate_class_template): Don't call add_friends.
(tsubst_default_argument): Use DECL_CONTEXT, not
DECL_REAL_CONTEXT.
(tsubst_decl): Set DECL_VIRTUAL_CONTEXT, not DECL_CLASS_CONTEXT.
Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
(set_meangled_name_for_template_decl): Use DECL_CONTEXT, not
DECL_CLASS_CONTEXT.
* repo.c (repo_inline_used): Likewise.
* search.c (current_scope): Adjust for new _CONTEXT macros.
(context_for_name_lookup): Use CP_DECL_CONTEXT, not
DECL_REAL_CONTEXT.
(friend_accessible_p): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
(lookup_fnfields_here):Likewise.
(check_final_overrider): Likewise.
(init_vbase_pointers): Likewise.
(virtual_context): Likewise.
* semantics.c (finish_member_declaration): Just set DECL_CONTEXT.
(expand_body): Use decl_function_context, not
hack_decl_function_context.
* tree.c (hack_decl_function_context): Remove.
* typeck.c (build_x_function_call): Use DECL_CONTEXT, not
DECL_CLASS_CONTEXT.
* typeck2.c (error_not_base_type): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32018 138bc75d-0d04-0410-961f-82ee72b054a4

18 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/dump.c
gcc/cp/error.c
gcc/cp/friend.c
gcc/cp/lex.c
gcc/cp/method.c
gcc/cp/pt.c
gcc/cp/repo.c
gcc/cp/search.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index 4802c50..537630f 100644 (file)
@@ -1,3 +1,108 @@
+2000-02-16  Mark Mitchell  <mark@codesourcery.com>
+
+       Make DECL_CONTEXT mean the class in which a member function was
+       declared, even for a virtual function.
+       * cp-tree.h (DECL_CLASS_CONTEXT): Adjust.
+       (DECL_FRIEND_CONTEXT): New macro.
+       (DECL_REAL_CONTEXT): Remove.
+       (SET_DECL_FRIEND_CONTEXT): Likewise.
+       (DECL_VIRTUAL_CONTEXT): Adjust.
+       (DECL_CLASS_SCOPE_P): Use TYPE_P.
+       (add_friends): Remove.
+       (hack_decl_function_context): Likewise.
+       * call.c (build_new_function_call): Replace DECL_REAL_CONTEXT with
+       CP_DECL_CONTEXT.
+       (build_over_call): Fix indentation.  Use DECL_CONTEXT
+       instead of DECL_CLASS_CONTEXT.
+       * class.c (dfs_build_vcall_offset_vtbl_entries): Likewise.
+       (add_method): Set DECL_VIRTUAL_CONTEXT, not DECL_CLASS_CONTEXT.
+       (strictly_overrides): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
+       (build_vtbl_or_vbase_field): Don't set DECL_CLASS_CONTEXT.
+       (build_base_field): Likewise.
+       (finish_struct_1): Likewise.
+       (build_self_reference): Likewise.
+       * decl.c (push_class_binding): Use CP_DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       (pushtag): Use decl_function_context, not
+       hack_decl_function_context.
+       (decls_match): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
+       (duplicate_decls): Use DECL_VIRTUAL_CONTEXT.
+       (pushdecl): Remove bogus code.
+       (start_decl): Use DECL_CONTEXT rather than DECL_CLASS_CONTEXT.
+       (cp_finish_decl): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
+       (grokfndecl): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
+       Use decl_function_context, nothack_decl_function_context.
+       (grokvardecl): Don't set DECL_CLASS_CONTEXT.
+       (grokdeclarator): Likewise.  Use decl_function_context, not
+       hack_decl_function_context.
+       (copy_args_p): Document.  Don't use DECL_CLASS_CONTEXT.
+       (start_function): Use DECL_FRIEND_CONTEXT, not
+       DECL_CLASS_CONTEXT.  Use decl_function_context, not
+       hack_decl_function_context.
+       (finish_function): Use decl_function_context, not
+       hack_decl_function_context.
+       (maybe_retrofit_in_chrg): Use DECL_CONTEXT, not
+       DECL_CLASS_CONTEXT.
+       (grokclassfn): Set DECL_VIRTUAL_CONTEXT, not DECL_CONTEXT.
+       (finish_static_data_member_decl): Don't set DECL_CLASS_CONTEXT.
+       (grokfield): Likewise.
+       (finish_builtin_type): Likewise.
+       (finish_vtable_vardec): Use decl_function_context, not
+       hack_decl_function_context.
+       (import_export_decl): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
+       (start_static_initialization_or_destruction): Likewise.
+       (finish_static_initialization_or_destruction): Likewise.
+       (mark_used): Adjust logic for deciding when to synthesize methods.
+       * dump.c (dequeue_and_dump): Use CP_DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       * error.c (dump_function_decl): Use DECL_CONTEXT, not
+       DECL_CLASS_CONTEXT.
+       * friend.c (is_friend): Likewise.
+       (add_friends): Remove.
+       (do_friend): Use SET_DECL_FRIEND_CONTEXT.
+       * lex.c (begin_definition_of_inclass_inline): Use
+       decl_function_context, not hack_decl_function_context.
+       (process_next_inline): Likewise.
+       (do_identifier): Use CP_DECL_CONTEXT, not DECL_REAL_CONTEXT.
+       * method.c (set_mangled_name_for_decl): Use DECL_CONTEXT, not
+       DECL_CLASSS_CONTEXT.
+       (hack_identifier): Likewise.
+       (synthesize_method):  Use decl_function_context, not
+       hack_decl_function_context.
+       * pt.c (template_class_depth_real): Use CP_DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       (is_member_template): Use decl_function_context, not
+       hack_decl_function_context.  Use DECL_CONTEXT, not
+       DECL_CLASS_CONTEXT.
+       (build_template_decl): Set DECL_VIRTUAL_CONTEXT, not 
+       DECL_CLASS_CONTEXT.
+       (check_default_tmpl_args): Use CP_DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       (push_template_decl_real): Likewise.
+       (instantiate_class_template): Don't call add_friends.
+       (tsubst_default_argument): Use DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       (tsubst_decl): Set DECL_VIRTUAL_CONTEXT, not DECL_CLASS_CONTEXT.
+       Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
+       (set_meangled_name_for_template_decl): Use DECL_CONTEXT, not
+       DECL_CLASS_CONTEXT.
+       * repo.c (repo_inline_used): Likewise.
+       * search.c (current_scope): Adjust for new _CONTEXT macros.
+       (context_for_name_lookup): Use CP_DECL_CONTEXT, not
+       DECL_REAL_CONTEXT.
+       (friend_accessible_p): Use DECL_CONTEXT, not DECL_CLASS_CONTEXT.
+       (lookup_fnfields_here):Likewise.
+       (check_final_overrider): Likewise.
+       (init_vbase_pointers): Likewise.
+       (virtual_context): Likewise.
+       * semantics.c (finish_member_declaration): Just set DECL_CONTEXT.
+       (expand_body): Use decl_function_context, not
+       hack_decl_function_context.
+       * tree.c (hack_decl_function_context): Remove.
+       * typeck.c (build_x_function_call): Use DECL_CONTEXT, not
+       DECL_CLASS_CONTEXT.
+       * typeck2.c (error_not_base_type): Likewise.
+       
 2000-02-15  Jason Merrill  <jason@casey.cygnus.com>
 
        * decl.c (xref_tag): Don't SET_IDENTIFIER_NAMESPACE_VALUE.
index 241c0ec..b78a0e4 100644 (file)
@@ -2504,7 +2504,7 @@ build_new_function_call (fn, args)
              (candidates, t, args, LOOKUP_NORMAL);
 
          if (candidates != old_candidates)
-           candidates->basetype_path = DECL_REAL_CONTEXT (t);
+           candidates->basetype_path = CP_DECL_CONTEXT (t);
        }
 
       if (! any_viable (candidates))
@@ -4030,7 +4030,7 @@ build_over_call (cand, args, flags)
     /* Do things the hard way.  */;
   else if (DECL_CONSTRUCTOR_P (fn)
           && TREE_VEC_LENGTH (convs) == 1
-      && copy_args_p (fn))
+          && copy_args_p (fn))
     {
       tree targ;
       arg = TREE_CHAIN (converted_args);
@@ -4098,7 +4098,7 @@ build_over_call (cand, args, flags)
             and we will call a destructor for it, which is wrong,
             because we will also destroy TO, but will never have
             constructed it.  */
-         val = build (is_empty_class (DECL_CLASS_CONTEXT (fn))
+         val = build (is_empty_class (DECL_CONTEXT (fn))
                       ? MODIFY_EXPR : INIT_EXPR, 
                       DECL_CONTEXT (fn), to, arg);
          address = build_unary_op (ADDR_EXPR, val, 0);
@@ -4110,7 +4110,7 @@ build_over_call (cand, args, flags)
     }
   else if (DECL_NAME (fn) == ansi_opname[MODIFY_EXPR]
           && copy_args_p (fn)
-          && TYPE_HAS_TRIVIAL_ASSIGN_REF (DECL_CLASS_CONTEXT (fn)))
+          && TYPE_HAS_TRIVIAL_ASSIGN_REF (DECL_CONTEXT (fn)))
     {
       tree to = stabilize_reference
        (build_indirect_ref (TREE_VALUE (converted_args), 0));
index 9b0bae5..2772d46 100644 (file)
@@ -409,7 +409,7 @@ dfs_build_vcall_offset_vtbl_entries (binfo, data)
 
       /* Figure out what function we're looking at.  */
       fn = TREE_VALUE (virtuals);
-      base = DECL_CLASS_CONTEXT (fn);
+      base = DECL_CONTEXT (fn);
 
       /* The FN is comes from BASE.  So, we must caculate the
         adjustment from the virtual base that derived from BINFO to
@@ -1428,10 +1428,10 @@ void
 add_method (type, fields, method)
      tree type, *fields, method;
 {
-  /* Setting the DECL_CONTEXT and DECL_CLASS_CONTEXT here is probably
-     redundant.  */
+  /* Setting the DECL_CONTEXT and DECL_VIRTUAL_CONTEXT 
+     here is probably redundant.  */
   DECL_CONTEXT (method) = type;
-  DECL_CLASS_CONTEXT (method) = type;
+  DECL_VIRTUAL_CONTEXT (method) = type;
   
   if (fields && *fields)
     *fields = build_overload (method, *fields);
@@ -3153,8 +3153,8 @@ static int
 strictly_overrides (fndecl1, fndecl2)
      tree fndecl1, fndecl2;
 {
-  int distance = get_base_distance (DECL_CLASS_CONTEXT (fndecl2),
-                                   DECL_CLASS_CONTEXT (fndecl1),
+  int distance = get_base_distance (DECL_CONTEXT (fndecl2),
+                                   DECL_CONTEXT (fndecl1),
                                    0, (tree *)0);
   if (distance == -2 || distance > 0)
     return 1;
@@ -4003,7 +4003,6 @@ build_vtbl_or_vbase_field (name, assembler_name, type, class_type, fcontext,
   DECL_VIRTUAL_P (field) = 1;
   DECL_ARTIFICIAL (field) = 1;
   DECL_FIELD_CONTEXT (field) = class_type;
-  DECL_CLASS_CONTEXT (field) = class_type;
   DECL_FCONTEXT (field) = fcontext;
   DECL_SAVED_INSNS (field) = 0;
   DECL_FIELD_SIZE (field) = 0;
@@ -4063,7 +4062,7 @@ build_base_field (t, binfo, empty_p, saw_empty_p, base_align)
   
   decl = build_lang_decl (FIELD_DECL, NULL_TREE, basetype);
   DECL_ARTIFICIAL (decl) = 1;
-  DECL_FIELD_CONTEXT (decl) = DECL_CLASS_CONTEXT (decl) = t;
+  DECL_FIELD_CONTEXT (decl) = t;
   DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype);
   DECL_ALIGN (decl) = CLASSTYPE_ALIGN (basetype);
   
@@ -4936,7 +4935,6 @@ finish_struct_1 (t)
       if (! integer_zerop (offset))
        offset = size_binop (MULT_EXPR, offset, size_int (BITS_PER_UNIT));
       DECL_FIELD_CONTEXT (vfield) = t;
-      DECL_CLASS_CONTEXT (vfield) = t;
       DECL_FIELD_BITPOS (vfield)
        = size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
       TYPE_VFIELD (t) = vfield;
@@ -6195,7 +6193,6 @@ build_self_reference ()
 
   DECL_NONLOCAL (value) = 1;
   DECL_CONTEXT (value) = current_class_type;
-  DECL_CLASS_CONTEXT (value) = current_class_type;
   DECL_ARTIFICIAL (value) = 1;
 
   if (processing_template_decl)
index d1eedc6..871d572 100644 (file)
@@ -1984,12 +1984,24 @@ struct lang_decl
   (DECL_LANG_SPECIFIC(NODE)->decl_flags.pretty_function_p)
 
 /* The _TYPE context in which this _DECL appears.  This field holds the
-   class where a virtual function instance is actually defined, and the
-   lexical scope of a friend function defined in a class body. */
-#define DECL_CLASS_CONTEXT(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.context)
-#define DECL_REAL_CONTEXT(NODE) \
-  ((TREE_CODE (NODE) == FUNCTION_DECL && DECL_FUNCTION_MEMBER_P (NODE)) \
-   ? DECL_CLASS_CONTEXT (NODE) : CP_DECL_CONTEXT (NODE))
+   class where a virtual function instance is actually defined. */
+#define DECL_CLASS_CONTEXT(NODE) \
+  (DECL_CLASS_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : NULL_TREE)
+
+/* For a non-member friend function, the class (if any) in which this
+   friend was defined.  For example, given:
+   
+     struct S { friend void f (); };
+
+   the DECL_FRIEND_CONTEXT for `f' will be `S'.  */
+#define DECL_FRIEND_CONTEXT(NODE)                              \
+  ((DECL_FRIEND_P (NODE) && !DECL_FUNCTION_MEMBER_P (NODE))    \
+   ? DECL_LANG_SPECIFIC (NODE)->decl_flags.context              \
+   : NULL_TREE)
+
+/* Set the DECL_FRIEND_CONTEXT for NODE to CONTEXT.  */
+#define SET_DECL_FRIEND_CONTEXT(NODE, CONTEXT) \
+  (DECL_LANG_SPECIFIC (NODE)->decl_flags.context = (CONTEXT))
 
 /* NULL_TREE in DECL_CONTEXT represents the global namespace. */
 #define CP_DECL_CONTEXT(NODE) \
@@ -1998,7 +2010,8 @@ struct lang_decl
 
 /* For a virtual function, the base where we find its vtable entry.
    For a non-virtual function, the base where it is defined.  */
-#define DECL_VIRTUAL_CONTEXT(NODE) DECL_CONTEXT (NODE)
+#define DECL_VIRTUAL_CONTEXT(NODE) \
+  (DECL_LANG_SPECIFIC (NODE)->decl_flags.context)
 
 /* 1 iff NODE has namespace scope, including the global namespace.  */
 #define DECL_NAMESPACE_SCOPE_P(NODE)                           \
@@ -2007,8 +2020,7 @@ struct lang_decl
 
 /* 1 iff NODE is a class member.  */
 #define DECL_CLASS_SCOPE_P(NODE) \
-  (DECL_CONTEXT (NODE) \
-   && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (NODE))) == 't')
+  (DECL_CONTEXT (NODE) && TYPE_P (DECL_CONTEXT (NODE)))
 
 /* 1 iff NODE is function-local.  */
 #define DECL_FUNCTION_SCOPE_P(NODE) \
@@ -3867,7 +3879,6 @@ extern tree cplus_expand_constant               PARAMS ((tree));
 extern int is_friend                           PARAMS ((tree, tree));
 extern void make_friend_class                  PARAMS ((tree, tree));
 extern void add_friend                          PARAMS ((tree, tree));
-extern void add_friends                         PARAMS ((tree, tree, tree));
 extern tree do_friend                          PARAMS ((tree, tree, tree, tree, tree, enum overload_flags, tree, int));
 
 /* in init.c */
@@ -4252,7 +4263,6 @@ extern tree array_type_nelts_top          PARAMS ((tree));
 extern tree break_out_target_exprs             PARAMS ((tree));
 extern tree get_type_decl                      PARAMS ((tree));
 extern tree vec_binfo_member                   PARAMS ((tree, tree));
-extern tree hack_decl_function_context                 PARAMS ((tree));
 extern tree decl_namespace_context             PARAMS ((tree));
 extern tree lvalue_type                                PARAMS ((tree));
 extern tree error_type                         PARAMS ((tree));
index 5a98bcb..b2d07ed 100644 (file)
@@ -1005,12 +1005,12 @@ push_class_binding (id, decl)
       else
        {
          if (TREE_CODE (decl) == OVERLOAD)
-           context = DECL_REAL_CONTEXT (OVL_CURRENT (decl));
+           context = CP_DECL_CONTEXT (OVL_CURRENT (decl));
          else
            {
              my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd',
                                  0);
-             context = DECL_REAL_CONTEXT (decl);
+             context = CP_DECL_CONTEXT (decl);
            }
 
          if (is_properly_derived_from (current_class_type, context))
@@ -2662,7 +2662,7 @@ pushtag (name, type, globalize)
                /* When declaring a friend class of a local class, we want
                   to inject the newly named class into the scope
                   containing the local class, not the namespace scope.  */
-               context = hack_decl_function_context (get_type_decl (cs));
+               context = decl_function_context (get_type_decl (cs));
            }
          if (!context)
            context = current_namespace;
@@ -2805,7 +2805,7 @@ decls_match (newdecl, olddecl)
       tree p1 = TYPE_ARG_TYPES (f1);
       tree p2 = TYPE_ARG_TYPES (f2);
 
-      if (DECL_REAL_CONTEXT (newdecl) != DECL_REAL_CONTEXT (olddecl)
+      if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)
          && ! (DECL_LANGUAGE (newdecl) == lang_c
                && DECL_LANGUAGE (olddecl) == lang_c))
        return 0;
@@ -3070,7 +3070,7 @@ duplicate_decls (newdecl, olddecl)
     }
   else if (!types_match)
     {
-      if (DECL_REAL_CONTEXT (newdecl) != DECL_REAL_CONTEXT (olddecl))
+      if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl))
        /* These are certainly not duplicate declarations; they're
           from different scopes.  */
        return 0;
@@ -3255,10 +3255,10 @@ duplicate_decls (newdecl, olddecl)
         definition.  */
       if (DECL_VINDEX (olddecl))
        DECL_VINDEX (newdecl) = DECL_VINDEX (olddecl);
+      if (DECL_VIRTUAL_CONTEXT (olddecl))
+       DECL_VIRTUAL_CONTEXT (newdecl) = DECL_VIRTUAL_CONTEXT (olddecl);
       if (DECL_CONTEXT (olddecl))
        DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
-      if (DECL_CLASS_CONTEXT (olddecl))
-       DECL_CLASS_CONTEXT (newdecl) = DECL_CLASS_CONTEXT (olddecl);
       if (DECL_PENDING_INLINE_INFO (newdecl) == (struct pending_inline *)0)
        DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl);
       DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl);
@@ -3641,8 +3641,6 @@ pushdecl (x)
             scoped of the current namespace, not the current
             function.  */
          && !(TREE_CODE (x) == VAR_DECL && DECL_EXTERNAL (x))
-         /* Don't change DECL_CONTEXT of virtual methods.  */
-         && (TREE_CODE (x) != FUNCTION_DECL || !DECL_VIRTUAL_P (x))
          && !DECL_CONTEXT (x))
        DECL_CONTEXT (x) = current_function_decl;
       if (!DECL_CONTEXT (x))
@@ -6713,10 +6711,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
   if (type == error_mark_node)
     return NULL_TREE;
 
-  context
-    = (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
-      ? DECL_CLASS_CONTEXT (decl)
-      : DECL_CONTEXT (decl);
+  context = DECL_CONTEXT (decl);
 
   if (initialized && context && TREE_CODE (context) == NAMESPACE_DECL
       && context != current_namespace && TREE_CODE (decl) == VAR_DECL)
@@ -7690,7 +7685,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags)
     }
 
   if (current_class_type
-      && DECL_REAL_CONTEXT (decl) == current_class_type
+      && CP_DECL_CONTEXT (decl) == current_class_type
       && TYPE_BEING_DEFINED (current_class_type)
       && (DECL_INITIAL (decl) || init))
     DECL_DEFINED_IN_CLASS_P (decl) = 1;
@@ -7855,7 +7850,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags)
         due to initialization of qualified member variable.
         I.e., Foo::x = 10;  */
       {
-       tree context = DECL_REAL_CONTEXT (decl);
+       tree context = CP_DECL_CONTEXT (decl);
        if (context
            && TREE_CODE_CLASS (TREE_CODE (context)) == 't'
            && (TREE_CODE (decl) == VAR_DECL
@@ -8465,7 +8460,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
     }
 
   if (ctype)
-    DECL_CLASS_CONTEXT (decl) = ctype;
+    DECL_CONTEXT (decl) = ctype;
 
   if (ctype == NULL_TREE && DECL_MAIN_P (decl))
     {
@@ -8482,7 +8477,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
   /* Members of anonymous types and local classes have no linkage; make
      them internal.  */
   if (ctype && (ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype))
-               || hack_decl_function_context (TYPE_MAIN_DECL (ctype))))
+               || decl_function_context (TYPE_MAIN_DECL (ctype))))
     publicp = 0;
 
   if (publicp)
@@ -8530,7 +8525,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
   if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
     grok_op_properties (decl, virtualp, check < 0);
 
-  if (ctype && hack_decl_function_context (decl))
+  if (ctype && decl_function_context (decl))
     DECL_NO_STATIC_CHAIN (decl) = 1;
 
   for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
@@ -8719,7 +8714,6 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
       type = TREE_TYPE (type);
       decl = build_lang_decl (VAR_DECL, declarator, type);
       DECL_CONTEXT (decl) = basetype;
-      DECL_CLASS_CONTEXT (decl) = basetype;
       DECL_ASSEMBLER_NAME (decl) = build_static_name (basetype, declarator);
     }
   else
@@ -10488,7 +10482,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                  template_count += 1;
                t = TYPE_MAIN_DECL (t);
                if (DECL_LANG_SPECIFIC (t))
-                 t = DECL_CLASS_CONTEXT (t);
+                 t = DECL_CONTEXT (t);
                else
                  t = NULL_TREE;
              }
@@ -10975,7 +10969,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
 
            /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node.  */
            function_context = (ctype != NULL_TREE) ?
-             hack_decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE;
+             decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE;
            publicp = (! friendp || ! staticp)
              && function_context == NULL_TREE;
            decl = grokfndecl (ctype, type,
@@ -11718,17 +11712,26 @@ replace_defarg (arg, init)
   TREE_PURPOSE (arg) = init;
 }
 \f
+/* D is a constructor or overloaded `operator='.  Returns non-zero if
+   D's arguments allow it to be a copy constructor, or copy assignment
+   operator.  */
+
 int
 copy_args_p (d)
      tree d;
 {
-  tree t = FUNCTION_ARG_CHAIN (d);
+  tree t;
+
+  if (!DECL_FUNCTION_MEMBER_P (d))
+    return 0;
+
+  t = FUNCTION_ARG_CHAIN (d);
   if (DECL_CONSTRUCTOR_P (d)
       && TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (d)))
     t = TREE_CHAIN (t);
   if (t && TREE_CODE (TREE_VALUE (t)) == REFERENCE_TYPE
       && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (t)))
-         == DECL_CLASS_CONTEXT (d))
+         == DECL_CONTEXT (d))
       && (TREE_CHAIN (t) == NULL_TREE
          || TREE_CHAIN (t) == void_list_node
          || TREE_PURPOSE (TREE_CHAIN (t))))
@@ -12972,7 +12975,7 @@ start_function (declspecs, declarator, attrs, flags)
         defined.  */
       if (!ctype && DECL_FRIEND_P (decl1))
        {
-         ctype = DECL_CLASS_CONTEXT (decl1);
+         ctype = DECL_FRIEND_CONTEXT (decl1);
 
          /* CTYPE could be null here if we're dealing with a template;
             for example, `inline friend float foo()' inside a template
@@ -13216,7 +13219,7 @@ start_function (declspecs, declarator, attrs, flags)
 
   if (DECL_INTERFACE_KNOWN (decl1))
     {
-      tree ctx = hack_decl_function_context (decl1);
+      tree ctx = decl_function_context (decl1);
 
       if (DECL_NOT_REALLY_EXTERN (decl1))
        DECL_EXTERNAL (decl1) = 0;
@@ -13273,7 +13276,7 @@ start_function (declspecs, declarator, attrs, flags)
       if ((DECL_THIS_INLINE (decl1) || DECL_TEMPLATE_INSTANTIATION (decl1))
          && ! DECL_INTERFACE_KNOWN (decl1)
          /* Don't try to defer nested functions for now.  */
-         && ! hack_decl_function_context (decl1))
+         && ! decl_function_context (decl1))
        DECL_DEFER_OUTPUT (decl1) = 1;
       else
        DECL_INTERFACE_KNOWN (decl1) = 1;
@@ -13921,7 +13924,7 @@ finish_function (lineno, flags)
       can_reach_end = 0;
 
       if (DECL_CONTEXT (fndecl) != NULL_TREE
-         && hack_decl_function_context (fndecl))
+         && decl_function_context (fndecl))
        /* Trick rest_of_compilation into not deferring output of this
           function, even if it is inline, since the rtl_obstack for
           this function is the function_obstack of the enclosing
index 6776715..245ec1f 100644 (file)
@@ -922,7 +922,7 @@ maybe_retrofit_in_chrg (fn)
   tree basetype, arg_types, parms, parm, fntype;
 
   if (DECL_CONSTRUCTOR_P (fn)
-      && TYPE_USES_VIRTUAL_BASECLASSES (DECL_CLASS_CONTEXT (fn))
+      && TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (fn))
       && ! DECL_CONSTRUCTOR_FOR_VBASE_P (fn))
     /* OK */;
   else if (! DECL_CONSTRUCTOR_P (fn)
@@ -1017,7 +1017,7 @@ grokclassfn (ctype, function, flags, quals)
   DECL_ARGUMENTS (function) = last_function_parms;
   /* First approximations.  */
   DECL_CONTEXT (function) = ctype;
-  DECL_CLASS_CONTEXT (function) = ctype;
+  DECL_VIRTUAL_CONTEXT (function) = ctype;
 
   if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
     maybe_retrofit_in_chrg (function);
@@ -1517,7 +1517,6 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
   DECL_INITIAL (decl) = init;
   DECL_IN_AGGR_P (decl) = 1;
   DECL_CONTEXT (decl) = current_class_type;
-  DECL_CLASS_CONTEXT (decl) = current_class_type;
 
   cp_finish_decl (decl, init, asmspec_tree, flags);
 }
@@ -1601,7 +1600,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
     {
       DECL_NONLOCAL (value) = 1;
       DECL_CONTEXT (value) = current_class_type;
-      DECL_CLASS_CONTEXT (value) = current_class_type;
 
       /* Now that we've updated the context, we need to remangle the
         name for this TYPE_DECL.  */
@@ -2182,7 +2180,6 @@ finish_builtin_type (type, name, fields, len, align_type)
       TREE_CHAIN (fields[i]) = fields[i+1];
     }
   DECL_FIELD_CONTEXT (fields[i]) = type;
-  DECL_CLASS_CONTEXT (fields[i]) = type;
   TYPE_ALIGN (type) = TYPE_ALIGN (align_type);
   layout_type (type);
 #if 0 /* not yet, should get fixed properly later */
@@ -2551,7 +2548,7 @@ finish_vtable_vardecl (t, data)
 
   if (! DECL_EXTERNAL (vars)
       && (DECL_NEEDED_P (vars)
-         || (hack_decl_function_context (vars) && TREE_USED (vars)))
+         || (decl_function_context (vars) && TREE_USED (vars)))
       && ! TREE_ASM_WRITTEN (vars))
     {
       if (TREE_TYPE (vars) == void_type_node)
@@ -2660,7 +2657,7 @@ import_export_decl (decl)
     }
   else if (DECL_FUNCTION_MEMBER_P (decl))
     {
-      tree ctype = DECL_CLASS_CONTEXT (decl);
+      tree ctype = DECL_CONTEXT (decl);
       import_export_class (ctype);
       if (CLASSTYPE_INTERFACE_KNOWN (ctype)
          && (flag_new_abi
@@ -3109,7 +3106,7 @@ start_static_initialization_or_destruction (decl, initp)
      which the DECL is a member.  */
   if (member_p (decl))
     {
-      DECL_CLASS_CONTEXT (current_function_decl) = DECL_CONTEXT (decl);
+      DECL_CONTEXT (current_function_decl) = DECL_CONTEXT (decl);
       DECL_STATIC_FUNCTION_P (current_function_decl) = 1;
     }
   
@@ -3174,7 +3171,7 @@ finish_static_initialization_or_destruction (sentry_if_stmt)
 
   /* Now that we're done with DECL we don't need to pretend to be a
      member of its class any longer.  */
-  DECL_CLASS_CONTEXT (current_function_decl) = NULL_TREE;
+  DECL_CONTEXT (current_function_decl) = NULL_TREE;
   DECL_STATIC_FUNCTION_P (current_function_decl) = 0;
 }
 
@@ -5202,8 +5199,10 @@ mark_used (decl)
   assemble_external (decl);
 
   /* Is it a synthesized method that needs to be synthesized?  */
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_CLASS_CONTEXT (decl)
-      && DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
+  if (TREE_CODE (decl) == FUNCTION_DECL
+      && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
+      && DECL_ARTIFICIAL (decl) 
+      && ! DECL_INITIAL (decl)
       /* Kludge: don't synthesize for default args.  */
       && current_function_decl)
     synthesize_method (decl);
index 34444bb..d4c23fe 100644 (file)
@@ -556,7 +556,7 @@ dequeue_and_dump (di)
 
     case FUNCTION_DECL:
     case THUNK_DECL:
-      dump_child ("scpe", DECL_REAL_CONTEXT (t));
+      dump_child ("scpe", CP_DECL_CONTEXT (t));
       dump_child ("mngl", DECL_ASSEMBLER_NAME (t));
       dump_child ("args", DECL_ARGUMENTS (t));
       if (DECL_EXTERNAL (t))
index d0196f5..e403f9f 100644 (file)
@@ -1131,9 +1131,8 @@ dump_function_decl (t, flags)
   fntype = TREE_TYPE (t);
   parmtypes = TYPE_ARG_TYPES (fntype);
 
-  /* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT.  */
   if (DECL_CLASS_SCOPE_P (t))
-    cname = DECL_CLASS_CONTEXT (t);
+    cname = DECL_CONTEXT (t);
   /* this is for partially instantiated template methods */
   else if (TREE_CODE (fntype) == METHOD_TYPE)
     cname = TREE_TYPE (TREE_VALUE (parmtypes));
@@ -2148,12 +2147,7 @@ lang_decl_name (decl, v)
 
   if (v == 1 && DECL_CLASS_SCOPE_P (decl))
     {
-      tree cname;
-      if (TREE_CODE (decl) == FUNCTION_DECL)
-       cname = DECL_CLASS_CONTEXT (decl);
-      else
-       cname = DECL_CONTEXT (decl);
-      dump_type (cname, TS_PLAIN);
+      dump_type (CP_DECL_CONTEXT (decl), TS_PLAIN);
       OB_PUTS ("::");
     }
 
index 6baf52d..1fc5794 100644 (file)
@@ -49,12 +49,6 @@ is_friend (type, supplicant)
     {
       tree list = DECL_FRIENDLIST (TYPE_MAIN_DECL (type));
       tree name = DECL_NAME (supplicant);
-      tree ctype;
-
-      if (DECL_FUNCTION_MEMBER_P (supplicant))
-       ctype = DECL_CLASS_CONTEXT (supplicant);
-      else
-       ctype = NULL_TREE;
 
       for (; list ; list = TREE_CHAIN (list))
        {
@@ -63,9 +57,6 @@ is_friend (type, supplicant)
              tree friends = FRIEND_DECLS (list);
              for (; friends ; friends = TREE_CHAIN (friends))
                {
-                 if (same_type_p (ctype, TREE_PURPOSE (friends)))
-                   return 1;
-
                  if (TREE_VALUE (friends) == NULL_TREE)
                    continue;
 
@@ -122,10 +113,10 @@ is_friend (type, supplicant)
     }      
 
   if (declp && DECL_FUNCTION_MEMBER_P (supplicant))
-    context = DECL_CLASS_CONTEXT (supplicant);
+    context = DECL_CONTEXT (supplicant);
   else if (! declp)
     /* Local classes have the same access as the enclosing function.  */
-    context = hack_decl_function_context (TYPE_MAIN_DECL (supplicant));
+    context = decl_function_context (TYPE_MAIN_DECL (supplicant));
   else
     context = NULL_TREE;
 
@@ -190,47 +181,6 @@ add_friend (type, decl)
                   DECL_BEFRIENDING_CLASSES (decl));
 }
 
-/* Declare that every member function NAME in FRIEND_TYPE
-   (which may be NULL_TREE) is a friend of type TYPE.  */
-
-void
-add_friends (type, name, friend_type)
-     tree type, name, friend_type;
-{
-  tree typedecl = TYPE_MAIN_DECL (type);
-  tree list = DECL_FRIENDLIST (typedecl);
-
-  while (list)
-    {
-      if (name == FRIEND_NAME (list))
-       {
-         tree friends = FRIEND_DECLS (list);
-         while (friends && TREE_PURPOSE (friends) != friend_type)
-           friends = TREE_CHAIN (friends);
-         if (friends)
-           {
-             if (friend_type)
-               warning ("method `%s::%s' is already a friend of class",
-                        TYPE_NAME_STRING (friend_type),
-                        IDENTIFIER_POINTER (name));
-             else
-               warning ("function `%s' is already a friend of class `%s'",
-                        IDENTIFIER_POINTER (name),
-                        IDENTIFIER_POINTER (DECL_NAME (typedecl)));
-           }
-         else
-           TREE_VALUE (list) = tree_cons (friend_type, NULL_TREE,
-                                          TREE_VALUE (list));
-         return;
-       }
-      list = TREE_CHAIN (list);
-    }
-  DECL_FRIENDLIST (typedecl)
-    = tree_cons (name,
-                build_tree_list (friend_type, NULL_TREE),
-                DECL_FRIENDLIST (typedecl));
-}
-
 /* Make FRIEND_TYPE a friend class to TYPE.  If FRIEND_TYPE has already
    been defined, we make all of its member functions friends of
    TYPE.  If not, we make it a pending friend, which can later be added
@@ -434,7 +384,7 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist,
         in their scope, their friend wind up in top-level scope as well.  */
       DECL_ARGUMENTS (decl) = parmdecls;
       if (funcdef_flag)
-       DECL_CLASS_CONTEXT (decl) = current_class_type;
+       SET_DECL_FRIEND_CONTEXT (decl, current_class_type);
 
       if (! DECL_USE_TEMPLATE (decl))
        {
index cedb837..7412598 100644 (file)
@@ -1278,7 +1278,7 @@ begin_definition_of_inclass_inline (pi)
   /* If this is an inline function in a local class, we must make sure
      that we save all pertinent information about the function
      surrounding the local class.  */
-  context = hack_decl_function_context (pi->fndecl);
+  context = decl_function_context (pi->fndecl);
   if (context)
     push_function_context_to (context);
 
@@ -1340,7 +1340,7 @@ process_next_inline (i)
      struct pending_inline *i;
 {
   tree context;
-  context = hack_decl_function_context (i->fndecl);  
+  context = decl_function_context (i->fndecl);  
   if (context)
     pop_function_context_from (context);
   i = i->next;
@@ -3176,7 +3176,7 @@ do_identifier (token, parsing, args)
     {
       /* Check access.  */
       if (IDENTIFIER_CLASS_VALUE (token) == id)
-       enforce_access (DECL_REAL_CONTEXT(id), id);
+       enforce_access (CP_DECL_CONTEXT(id), id);
       if (!processing_template_decl || DECL_TEMPLATE_PARM_P (id))
        id = DECL_INITIAL (id);
     }
index ddb0842..b48e80e 100644 (file)
@@ -1726,7 +1726,7 @@ set_mangled_name_for_decl (decl)
 
   if (DECL_STATIC_FUNCTION_P (decl))
     parm_types = 
-      hash_tree_chain (build_pointer_type (DECL_CLASS_CONTEXT (decl)),
+      hash_tree_chain (build_pointer_type (DECL_CONTEXT (decl)),
                                           parm_types);
   else
     /* The only member functions whose type is a FUNCTION_TYPE, rather
@@ -1930,7 +1930,7 @@ hack_identifier (value, name)
       if (TREE_CODE (value) == OVERLOAD)
        value = OVL_CURRENT (value);
 
-      decl = maybe_dummy_object (DECL_CLASS_CONTEXT (value), 0);
+      decl = maybe_dummy_object (DECL_CONTEXT (value), 0);
       value = build_component_ref (decl, name, NULL_TREE, 1);
     }
   else if (really_overloaded_fn (value))
@@ -1979,15 +1979,10 @@ hack_identifier (value, name)
   if (TREE_CODE_CLASS (TREE_CODE (value)) == 'd' && DECL_NONLOCAL (value))
     {
       if (DECL_CLASS_SCOPE_P (value)
-         && DECL_CLASS_CONTEXT (value) != current_class_type)
+         && DECL_CONTEXT (value) != current_class_type)
        {
          tree path;
-         register tree context
-           = (TREE_CODE (value) == FUNCTION_DECL && DECL_VIRTUAL_P (value))
-             ? DECL_CLASS_CONTEXT (value)
-             : DECL_CONTEXT (value);
-
-         path = currently_open_derived_class (context);
+         path = currently_open_derived_class (DECL_CONTEXT (value));
          enforce_access (path, value);
        }
     }
@@ -2349,7 +2344,7 @@ synthesize_method (fndecl)
      tree fndecl;
 {
   int nested = (current_function_decl != NULL_TREE);
-  tree context = hack_decl_function_context (fndecl);
+  tree context = decl_function_context (fndecl);
   int need_body = 1;
 
   if (at_eof)
index 64d3251..f132fa5 100644 (file)
@@ -244,7 +244,7 @@ template_class_depth_real (type, count_specializations)
   for (depth = 0; 
        type && TREE_CODE (type) != NAMESPACE_DECL;
        type = (TREE_CODE (type) == FUNCTION_DECL) 
-        ? DECL_REAL_CONTEXT (type) : TYPE_CONTEXT (type))
+        ? CP_DECL_CONTEXT (type) : TYPE_CONTEXT (type))
     {
       if (TREE_CODE (type) != FUNCTION_DECL)
        {
@@ -430,7 +430,7 @@ is_member_template (t)
     return 0;
 
   /* A local class can't have member templates.  */
-  if (hack_decl_function_context (t))
+  if (decl_function_context (t))
     return 0;
 
   return (DECL_FUNCTION_MEMBER_P (DECL_TEMPLATE_RESULT (t))
@@ -438,7 +438,7 @@ is_member_template (t)
             there are template classes surrounding the declaration,
             then we have a member template.  */
          && (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (t)) > 
-             template_class_depth (DECL_CLASS_CONTEXT (t))));
+             template_class_depth (DECL_CONTEXT (t))));
 }
 
 #if 0 /* UNUSED */
@@ -1934,7 +1934,7 @@ build_template_decl (decl, parms)
   DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl);
   if (DECL_LANG_SPECIFIC (decl))
     {
-      DECL_CLASS_CONTEXT (tmpl) = DECL_CLASS_CONTEXT (decl);
+      DECL_VIRTUAL_CONTEXT (tmpl) = DECL_VIRTUAL_CONTEXT (decl);
       DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl);
       DECL_CONSTRUCTOR_P (tmpl) = DECL_CONSTRUCTOR_P (decl);
       DECL_NONCONVERTING_P (tmpl) = DECL_NONCONVERTING_P (decl);
@@ -2197,7 +2197,7 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial)
      in the template-parameter-list of the definition of a member of a
      class template.  */
 
-  if (TREE_CODE (DECL_REAL_CONTEXT (decl)) == FUNCTION_DECL)
+  if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL)
     /* You can't have a function template declaration in a local
        scope, nor you can you define a member of a class template in a
        local scope.  */
@@ -2208,7 +2208,11 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial)
       && DECL_LANG_SPECIFIC (decl)
       /* If this is either a friend defined in the scope of the class
         or a member function.  */
-      && DECL_CLASS_CONTEXT (decl) == current_class_type
+      && ((DECL_CONTEXT (decl) 
+          && same_type_p (DECL_CONTEXT (decl), current_class_type))
+         || (DECL_FRIEND_CONTEXT (decl)
+             && same_type_p (DECL_FRIEND_CONTEXT (decl), 
+                             current_class_type)))
       /* And, if it was a member function, it really was defined in
         the scope of the class.  */
       && (!DECL_FUNCTION_MEMBER_P (decl) || DECL_DEFINED_IN_CLASS_P (decl)))
@@ -2348,11 +2352,11 @@ push_template_decl_real (decl, is_friend)
     /* For a friend, we want the context of the friend function, not
        the type of which it is a friend.  */
     ctx = DECL_CONTEXT (decl);
-  else if (DECL_REAL_CONTEXT (decl)
-          && TREE_CODE (DECL_REAL_CONTEXT (decl)) != NAMESPACE_DECL)
+  else if (CP_DECL_CONTEXT (decl)
+          && TREE_CODE (CP_DECL_CONTEXT (decl)) != NAMESPACE_DECL)
     /* In the case of a virtual function, we want the class in which
        it is defined.  */
-    ctx = DECL_REAL_CONTEXT (decl);
+    ctx = CP_DECL_CONTEXT (decl);
   else
     /* Otherwise, if we're currently definining some class, the DECL
        is assumed to be a member of the class.  */
@@ -5012,11 +5016,7 @@ instantiate_class_template (type)
                      tsubst_friend_function (TREE_VALUE (friends),
                                              args));
        else
-         add_friends (type, 
-                      tsubst_copy (TREE_PURPOSE (t), args,
-                                   /*complain=*/1, NULL_TREE),
-                      tsubst (TREE_PURPOSE (friends), args,
-                              /*complain=*/1, NULL_TREE));
+         my_friendly_abort (20000216);
     }
 
   for (t = CLASSTYPE_FRIEND_CLASSES (pattern);
@@ -5337,7 +5337,7 @@ tsubst_default_argument (fn, type, arg)
      we must be careful to do name lookup in the scope of S<T>,
      rather than in the current class.  */
   if (DECL_CLASS_SCOPE_P (fn))
-    pushclass (DECL_REAL_CONTEXT (fn), 2);
+    pushclass (DECL_CONTEXT (fn), 2);
 
   arg = tsubst_expr (arg, DECL_TI_ARGS (fn), /*complain=*/1, NULL_TREE);
   
@@ -5453,12 +5453,13 @@ tsubst_decl (t, args, type, in_decl)
          }
 
        DECL_CONTEXT (r) 
-         = tsubst_aggr_type (DECL_CONTEXT (t), args, /*complain=*/1,
-                             in_decl, /*entering_scope=*/1);
-       DECL_CLASS_CONTEXT (r) 
-         = tsubst_aggr_type (DECL_CLASS_CONTEXT (t), args, 
+         = tsubst_aggr_type (DECL_CONTEXT (t), args, 
                              /*complain=*/1, in_decl, 
                              /*entering_scope=*/1); 
+       DECL_VIRTUAL_CONTEXT (r) 
+         = tsubst_aggr_type (DECL_VIRTUAL_CONTEXT (t), args, 
+                             /*complain=*/1, in_decl, 
+                             /*entering_scope=*/1);
        DECL_TEMPLATE_INFO (r) = build_tree_list (t, args);
 
        if (TREE_CODE (decl) == TYPE_DECL)
@@ -5660,14 +5661,14 @@ tsubst_decl (t, args, type, in_decl)
              member = 2;
            else
              member = 1;
-           ctx = tsubst_aggr_type (DECL_CLASS_CONTEXT (t), args, 
+           ctx = tsubst_aggr_type (DECL_CONTEXT (t), args, 
                                    /*complain=*/1, t, 
                                    /*entering_scope=*/1);
          }
        else
          {
            member = 0;
-           ctx = NULL_TREE;
+           ctx = DECL_CONTEXT (t);
          }
        type = tsubst (type, args, /*complain=*/1, in_decl);
        if (type == error_mark_node)
@@ -5683,10 +5684,11 @@ tsubst_decl (t, args, type, in_decl)
        DECL_USE_TEMPLATE (r) = 0;
        TREE_TYPE (r) = type;
 
-       DECL_CONTEXT (r)
-         = tsubst_aggr_type (DECL_CONTEXT (t), args, /*complain=*/1, t,
+       DECL_CONTEXT (r) = ctx;
+       DECL_VIRTUAL_CONTEXT (r)
+         = tsubst_aggr_type (DECL_VIRTUAL_CONTEXT (t), args, 
+                             /*complain=*/1, t,
                              /*entering_scope=*/1);
-       DECL_CLASS_CONTEXT (r) = ctx;
 
        if (member && IDENTIFIER_TYPENAME_P (DECL_NAME (r)))
          /* Type-conversion operator.  Reconstruct the name, in
@@ -5909,7 +5911,6 @@ tsubst_decl (t, args, type, in_decl)
        DECL_RTL (r) = 0;
        DECL_SIZE (r) = 0;
        copy_lang_decl (r);
-       DECL_CLASS_CONTEXT (r) = DECL_CONTEXT (r);
 
        /* For __PRETTY_FUNCTION__ we have to adjust the initializer.  */
        if (DECL_PRETTY_FUNCTION_P (r))
@@ -9888,7 +9889,7 @@ set_mangled_name_for_template_decl (decl)
      with the innermost level omitted.  */
   fn_type = TREE_TYPE (tmpl);
   if (DECL_STATIC_FUNCTION_P (decl))
-    context = DECL_CLASS_CONTEXT (decl);
+    context = DECL_CONTEXT (decl);
 
   if (parm_depth == 1)
     /* No substitution is necessary.  */
index 7812823..b02af8a 100644 (file)
@@ -171,9 +171,9 @@ repo_inline_used (fn)
 
   /* Member functions of polymorphic classes go with their vtables.  */
   if (DECL_FUNCTION_MEMBER_P (fn) 
-      && TYPE_POLYMORPHIC_P (DECL_CLASS_CONTEXT (fn)))
+      && TYPE_POLYMORPHIC_P (DECL_CONTEXT (fn)))
     {
-      repo_vtable_used (DECL_CLASS_CONTEXT (fn));
+      repo_vtable_used (DECL_CONTEXT (fn));
       return;
     }
 
index a3544dd..7886f48 100644 (file)
@@ -692,7 +692,12 @@ current_scope ()
     return current_class_type;
   if (current_class_type == NULL_TREE)
     return current_function_decl;
-  if (DECL_CLASS_CONTEXT (current_function_decl) == current_class_type)
+  if ((DECL_FUNCTION_MEMBER_P (current_function_decl)
+       && same_type_p (DECL_CONTEXT (current_function_decl),
+                      current_class_type))
+      || (DECL_FRIEND_CONTEXT (current_function_decl)
+         && same_type_p (DECL_FRIEND_CONTEXT (current_function_decl),
+                         current_class_type)))
     return current_function_decl;
 
   return current_class_type;
@@ -721,7 +726,7 @@ context_for_name_lookup (decl)
      definition, the members of the anonymous union are considered to
      have been defined in the scope in which teh anonymous union is
      declared.  */ 
-  tree context = DECL_REAL_CONTEXT (decl);
+  tree context = CP_DECL_CONTEXT (decl);
 
   while (TYPE_P (context) && ANON_AGGR_TYPE_P (context))
     context = TYPE_CONTEXT (context);
@@ -1064,8 +1069,9 @@ friend_accessible_p (scope, type, decl, binfo)
     {
       /* Perhaps this SCOPE is a member of a class which is a 
         friend.  */ 
-      if (friend_accessible_p (DECL_CLASS_CONTEXT (scope), type,
-                              decl, binfo))
+      if (DECL_CLASS_SCOPE_P (decl)
+         && friend_accessible_p (DECL_CONTEXT (scope), type,
+                                 decl, binfo))
        return 1;
 
       /* Or an instantiation of something which is a friend.  */
@@ -1280,7 +1286,7 @@ lookup_fnfields_here (type, name)
   fndecls = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx);
   while (fndecls)
     {
-      if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (OVL_CURRENT (fndecls)))
+      if (TYPE_MAIN_VARIANT (DECL_CONTEXT (OVL_CURRENT (fndecls)))
          == TYPE_MAIN_VARIANT (type))
        return idx;
       fndecls = OVL_CHAIN (fndecls);
@@ -2044,7 +2050,7 @@ check_final_overrider (overrider, basefn)
       cp_error_at ("conflicting return type specified for `virtual %#D'", overrider);
       cp_error_at ("  overriding `virtual %#D'", basefn);
       SET_IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (overrider),
-                                  DECL_CLASS_CONTEXT (overrider));
+                                  DECL_CONTEXT (overrider));
       return 0;
     }
   
@@ -2810,11 +2816,11 @@ init_vbase_pointers (type, decl_ptr)
 }
 
 /* get the virtual context (the vbase that directly contains the
-   DECL_CLASS_CONTEXT of the FNDECL) that the given FNDECL is declared in,
+   DECL_CONTEXT of the FNDECL) that the given FNDECL is declared in,
    or NULL_TREE if there is none.
 
-   FNDECL must come from a virtual table from a virtual base to ensure that
-   there is only one possible DECL_CLASS_CONTEXT.
+   FNDECL must come from a virtual table from a virtual base to ensure
+   that there is only one possible DECL_CONTEXT.
 
    We know that if there is more than one place (binfo) the fndecl that the
    declared, they all refer to the same binfo.  See get_class_offset_1 for
@@ -2825,10 +2831,10 @@ virtual_context (fndecl, t, vbase)
      tree fndecl, t, vbase;
 {
   tree path;
-  if (get_base_distance (DECL_CLASS_CONTEXT (fndecl), t, 0, &path) < 0)
+  if (get_base_distance (DECL_CONTEXT (fndecl), t, 0, &path) < 0)
     {
-      /* DECL_CLASS_CONTEXT can be ambiguous in t.  */
-      if (get_base_distance (DECL_CLASS_CONTEXT (fndecl), vbase, 0, &path) >= 0)
+      /* DECL_CONTEXT can be ambiguous in t.  */
+      if (get_base_distance (DECL_CONTEXT (fndecl), vbase, 0, &path) >= 0)
        {
          while (path)
            {
index abe9fb1..cabe49a 100644 (file)
@@ -1990,14 +1990,7 @@ finish_member_declaration (decl)
     }
 
   /* Mark the DECL as a member of the current class.  */
-  if (TREE_CODE (decl) == FUNCTION_DECL 
-      || DECL_FUNCTION_TEMPLATE_P (decl))
-    /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
-       finish_struct.  Presumably it is already set as the function is
-       parsed.  Perhaps DECL_CLASS_CONTEXT is already set, too?  */
-    DECL_CLASS_CONTEXT (decl) = current_class_type;
-  else
-    DECL_CONTEXT (decl) = current_class_type;
+  DECL_CONTEXT (decl) = current_class_type;
 
   /* Put functions on the TYPE_METHODS list and everything else on the
      TYPE_FIELDS list.  Note that these are built up in reverse order.
@@ -2722,7 +2715,7 @@ expand_body (fn)
         DECL_COMDAT.  */
       && (!at_eof || DECL_COMDAT (fn))
       /* Or if this is a nested function.  */
-      && !hack_decl_function_context (fn))
+      && !decl_function_context (fn))
     {
       /* Give the function RTL now so that we can assign it to a
         function pointer, etc.  */
index a66a634..ae908fa 100644 (file)
@@ -1773,20 +1773,6 @@ vec_binfo_member (elem, vec)
   return NULL_TREE;
 }
 
-/* Kludge around the fact that DECL_CONTEXT for virtual functions returns
-   the wrong thing for decl_function_context.  Hopefully the uses in the
-   backend won't matter, since we don't need a static chain for local class
-   methods.  FIXME!  */
-
-tree
-hack_decl_function_context (decl)
-     tree decl;
-{
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_FUNCTION_MEMBER_P (decl))
-    return decl_function_context (TYPE_MAIN_DECL (DECL_CLASS_CONTEXT (decl)));
-  return decl_function_context (decl);
-}
-
 /* Returns the namespace that contains DECL, whether directly or
    indirectly.  */
 
index 1ffd7bc..8264ede 100644 (file)
@@ -2615,18 +2615,18 @@ build_x_function_call (function, params, decl)
       if (TREE_CODE (function) == FUNCTION_DECL
          || DECL_FUNCTION_TEMPLATE_P (function))
        {
-         basetype = DECL_CLASS_CONTEXT (function);
+         basetype = DECL_CONTEXT (function);
 
          if (DECL_NAME (function))
            function = DECL_NAME (function);
          else
-           function = TYPE_IDENTIFIER (DECL_CLASS_CONTEXT (function));
+           function = TYPE_IDENTIFIER (DECL_CONTEXT (function));
        }
       else if (TREE_CODE (function) == TREE_LIST)
        {
          my_friendly_assert (TREE_CODE (TREE_VALUE (function))
                              == FUNCTION_DECL, 312);
-         basetype = DECL_CLASS_CONTEXT (TREE_VALUE (function));
+         basetype = DECL_CONTEXT (TREE_VALUE (function));
          function = TREE_PURPOSE (function);
        }
       else if (TREE_CODE (function) != IDENTIFIER_NODE)
@@ -6269,7 +6269,7 @@ expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
   my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 0);
 
   /* The class that the function belongs to.  */
-  fn_class = DECL_CLASS_CONTEXT (fn);
+  fn_class = DECL_CONTEXT (fn);
 
   /* The class that we're creating a pointer to member of.  */
   ptr_class = TYPE_PTRMEMFUNC_OBJECT_TYPE (type);
index 6f35b36..3e90fb9 100644 (file)
@@ -49,7 +49,7 @@ error_not_base_type (basetype, type)
      tree basetype, type;
 {
   if (TREE_CODE (basetype) == FUNCTION_DECL)
-    basetype = DECL_CLASS_CONTEXT (basetype);
+    basetype = DECL_CONTEXT (basetype);
   cp_error ("type `%T' is not a base type for type `%T'", basetype, type);
   return error_mark_node;
 }