diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 794665eded7..09249c47683 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1998-06-09 Jason Merrill + + * search.c (lookup_member): New fn. + * class.c (finish_struct_1): Use it. + * decl.c (lookup_name_real): Use it. + Mon Jun 8 20:45:52 1998 Kaveh R. Ghazi * Makefile.in (decl2.o): Depend on dwarf2out.h and dwarfout.h. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c1f58bd5407..0e1aa26f422 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3210,9 +3210,7 @@ finish_struct_1 (t, warn_anon) || sname == constructor_name_full (ctype)) cp_error_at ("using-declaration for constructor", x); - fdecl = lookup_field (binfo, sname, 0, 0); - if (! fdecl) - fdecl = lookup_fnfields (binfo, sname, 0); + fdecl = lookup_member (binfo, sname, 0, 0); if (fdecl) access_decls = scratch_tree_cons (access, fdecl, access_decls); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d5c46173701..6324becec6b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2708,6 +2708,7 @@ extern tree compute_access PROTO((tree, tree)); extern tree lookup_field PROTO((tree, tree, int, int)); extern tree lookup_nested_field PROTO((tree, int)); extern tree lookup_fnfields PROTO((tree, tree, int)); +extern tree lookup_member PROTO((tree, tree, int, int)); extern tree lookup_nested_tag PROTO((tree, tree)); extern tree get_matching_virtual PROTO((tree, tree, int)); extern tree get_abstract_virtuals PROTO((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4804c9f70fc..dd7ddead613 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4816,7 +4816,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) else if (type == current_class_type) val = IDENTIFIER_CLASS_VALUE (name); else - val = lookup_field (type, name, 0, prefer_type); + val = lookup_member (type, name, 0, prefer_type); } else val = NULL_TREE; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 6d2a5309ff5..e92e8d8e2b5 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2005,6 +2005,35 @@ lookup_fnfields (basetype_path, name, complain) return rvals; } + +/* Look for a field or function named NAME in an inheritance lattice + dominated by XBASETYPE. PROTECT is zero if we can avoid computing + access information, otherwise it is 1. WANT_TYPE is 1 when we should + only return TYPE_DECLs, if no TYPE_DECL can be found return NULL_TREE. */ + +tree +lookup_member (xbasetype, name, protect, want_type) + tree xbasetype, name; + int protect, want_type; +{ + tree ret, basetype_path; + + if (TREE_CODE (xbasetype) == TREE_VEC) + basetype_path = xbasetype; + else if (IS_AGGR_TYPE_CODE (TREE_CODE (xbasetype))) + { + basetype_path = TYPE_BINFO (xbasetype); + BINFO_VIA_PUBLIC (basetype_path) = 1; + BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE; + } + else + my_friendly_abort (97); + + ret = lookup_field (basetype_path, name, protect, want_type); + if (! ret && ! want_type) + ret = lookup_fnfields (basetype_path, name, protect); + return ret; +} /* BREADTH-FIRST SEARCH ROUTINES. */