search.c (lookup_member): New fn.
authorJason Merrill <jason@yorick.cygnus.com>
Tue, 9 Jun 1998 12:10:57 +0000 (12:10 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 Jun 1998 12:10:57 +0000 (08:10 -0400)
* search.c (lookup_member): New fn.
* class.c (finish_struct_1): Use it.
* decl.c (lookup_name_real): Use it.

From-SVN: r20375

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/search.c

index 794665eded7ea29677d79a5edec09457aa84409e..09249c47683234a294ec2f678a900d1142b02b21 100644 (file)
@@ -1,3 +1,9 @@
+1998-06-09  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * 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  <ghazi@caip.rutgers.edu>
 
        * Makefile.in (decl2.o): Depend on dwarf2out.h and dwarfout.h.
index c1f58bd5407be48ebf99c604230179c88997c6c0..0e1aa26f422b121c4ebdc1277c5625aa431140a1 100644 (file)
@@ -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);
index d5c46173701dfbc7bc2dd0222ebcb1a8b56c145e..6324becec6b650f3fdb8e35f098da24e210a63b4 100644 (file)
@@ -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));
index 4804c9f70fc43d2630cc2acafc8492ee727fe7b9..dd7ddead613d843cfc90c71eed620ed4858b30cc 100644 (file)
@@ -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;
index 6d2a5309ff5991b5aec49e60f17782eec2ff67e2..e92e8d8e2b5ab0354f3ea759f2945cf480eaba2d 100644 (file)
@@ -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;
+}
 \f
 /* BREADTH-FIRST SEARCH ROUTINES.  */