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
+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.
(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))
/* 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);
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);
}
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));
/* 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
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);
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;
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;
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);
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;
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)
(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) \
/* 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) \
/* 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) \
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 */
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));
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))
/* 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;
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;
}
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;
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);
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))
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)
}
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;
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
}
if (ctype)
- DECL_CLASS_CONTEXT (decl) = ctype;
+ DECL_CONTEXT (decl) = ctype;
if (ctype == NULL_TREE && DECL_MAIN_P (decl))
{
/* 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)
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))
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
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;
}
/* 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,
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))))
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
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;
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;
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
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)
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);
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);
}
{
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. */
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 */
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)
}
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
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;
}
/* 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;
}
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);
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))
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));
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 ("::");
}
{
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))
{
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;
}
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;
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
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))
{
/* 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);
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;
{
/* 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);
}
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
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))
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);
}
}
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)
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)
{
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))
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 */
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);
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. */
&& 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)))
/* 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. */
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);
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);
}
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)
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)
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
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))
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. */
/* 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;
}
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;
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);
{
/* 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. */
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);
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;
}
}
/* 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
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)
{
}
/* 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.
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. */
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. */
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)
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);
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;
}