From 9ba4048d10611b32258f875ff8c93d81f2ceec31 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 16 Feb 2000 23:54:23 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32018 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/pt.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'gcc/cp/pt.c') diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 64d3251e75b..f132fa525d0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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, 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. */ -- cgit v1.2.1