diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-07-17 07:31:08 +0000 |
---|---|---|
committer | Mark Mitchell <mark@codesourcery.com> | 2004-07-17 07:31:08 +0000 |
commit | ad7c99954ab8c3cb8fcf3cee73318249fcc1f061 (patch) | |
tree | 2d69e1c139bcf0ee4f483089d38a6c6ff542bbce /gcc/cp/search.c | |
parent | 2e5bc4117b054a3aa3fa15eaa08dcd769f51f4ca (diff) |
* class.c (finish_struct_methods): Remove unncessary code.
(add_implicitly_declared_members): Create declarations for default
constructors and copy constructors lazily.
* cp-tree.h (lang_type_class): Remove lazy_default_ctor and
lazy_copy_ctor.
(CLASSTYPE_LAZY_DEFAULT_CTOR): New macro.
(CLASSTYPE_LAZY_COPY_CTOR): Likewise.
* decl2.c (check_classfn): Robustify.
(locate_dtor): Handle empty CLASSTYPE_METHOD_VEC.
(locate_ctor): Handle lazy default constructors.
(locate_copy): Handle lazy copy constructors.
(implicitly_declare_fn): Make sure we're looking at the
TYPE_MAIN_VARIANT for a class before creating functions. Don't
set TYPE_HAS_CONSTRUCTOR.
(lazily_declare_fn): New function.
* name-lookup.c (constructor_name_full): Simplify.
* search.c (lookup_fnfields_1): Lazily create methods, as
necessary.
(lookup_for_overrides): Handle empty CLASSTYPE_METHOD_VEC.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@84851 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r-- | gcc/cp/search.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 97b97899e4f..ceefa3cd05f 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1368,8 +1368,24 @@ lookup_fnfields_1 (tree type, tree name) if (!CLASS_TYPE_P (type)) return -1; - method_vec = CLASSTYPE_METHOD_VEC (type); + if (COMPLETE_TYPE_P (type)) + { + if ((name == ctor_identifier + || name == base_ctor_identifier + || name == complete_ctor_identifier)) + { + if (CLASSTYPE_LAZY_DEFAULT_CTOR (type)) + lazily_declare_fn (sfk_constructor, type); + if (CLASSTYPE_LAZY_COPY_CTOR (type)) + lazily_declare_fn (sfk_copy_constructor, type); + } + else if (name == ansi_assopname(NOP_EXPR) + && !TYPE_HAS_ASSIGN_REF (type) + && !TYPE_FOR_JAVA (type)) + lazily_declare_fn (sfk_assignment_operator, type); + } + method_vec = CLASSTYPE_METHOD_VEC (type); if (!method_vec) return -1; @@ -1405,24 +1421,6 @@ lookup_fnfields_1 (tree type, tree name) int lo; int hi; - /* All non-Java classes have "operator=" -- but we do not - actually create the declaration until it is needed. */ - if (name == ansi_assopname(NOP_EXPR) - && !TYPE_HAS_ASSIGN_REF (type) - && !TYPE_FOR_JAVA (type)) - { - tree fn; - - /* Declare the function. */ - fn = implicitly_declare_fn (sfk_assignment_operator, type, - TYPE_HAS_CONST_ASSIGN_REF (type)); - add_method (type, fn); - TREE_CHAIN (fn) = TYPE_METHODS (type); - TYPE_METHODS (type) = fn; - maybe_add_class_template_decl_list (type, fn, /*friend_p=*/0); - method_vec = CLASSTYPE_METHOD_VEC (type); - } - lo = i; hi = VEC_length (tree, method_vec); while (lo < hi) @@ -1789,6 +1787,12 @@ look_for_overrides_here (tree type, tree fndecl) { int ix; + /* If there are no methods in TYPE (meaning that only implicitly + declared methods will ever be provided for TYPE), then there are + no virtual functions. */ + if (!CLASSTYPE_METHOD_VEC (type)) + return NULL_TREE; + if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fndecl)) ix = CLASSTYPE_DESTRUCTOR_SLOT; else |