+/* Search through the base classes of PARENT_TYPE for a base class
+ named NAME and return its type. If not found, return NULL. */
+
+struct type *
+find_type_baseclass_by_name (struct type *parent_type, const char *name)
+{
+ int i;
+
+ CHECK_TYPEDEF (parent_type);
+ for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
+ {
+ struct type *type = check_typedef (TYPE_BASECLASS (parent_type, i));
+ const char *base_name = TYPE_BASECLASS_NAME (parent_type, i);
+
+ if (base_name == NULL)
+ continue;
+
+ if (streq (base_name, name))
+ return type;
+
+ type = find_type_baseclass_by_name (type, name);
+ if (type != NULL)
+ return type;
+ }
+
+ return NULL;
+}
+
+/* Search through the base classes of PARENT_TYPE for a symbol named
+ NAME in block BLOCK. */
+
+static struct symbol *
+find_symbol_in_baseclass (struct type *parent_type, const char *name,
+ const struct block *block)
+{
+ int i;
+ struct symbol *sym;
+ struct cleanup *cleanup;
+ char *concatenated_name;
+
+ sym = NULL;
+ concatenated_name = NULL;
+ cleanup = make_cleanup (free_current_contents, &concatenated_name);
+ for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
+ {
+ size_t len;
+ struct type *base_type = TYPE_BASECLASS (parent_type, i);
+ const char *base_name = TYPE_BASECLASS_NAME (parent_type, i);
+
+ if (base_name == NULL)
+ continue;
+
+ /* Search this particular base class. */
+ sym = cp_lookup_symbol_in_namespace (base_name, name, block,
+ VAR_DOMAIN, 0);
+ if (sym != NULL)
+ break;
+
+ /* Now search all static file-level symbols. We have to do this for
+ things like typedefs in the class. First search in this symtab,
+ what we want is possibly there. */
+ len = strlen (base_name) + 2 + strlen (name) + 1;
+ concatenated_name = xrealloc (concatenated_name, len);
+ xsnprintf (concatenated_name, len, "%s::%s", base_name, name);
+ sym = lookup_symbol_static (concatenated_name, block, VAR_DOMAIN);
+ if (sym != NULL)
+ break;
+
+ /* Nope. We now have to search all static blocks in all objfiles,
+ even if block != NULL, because there's no guarantees as to which
+ symtab the symbol we want is in. */
+ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+ if (sym != NULL)
+ break;
+
+ /* If this class has base classes, search them next. */
+ CHECK_TYPEDEF (base_type);
+ if (TYPE_N_BASECLASSES (base_type) > 0)
+ {
+ sym = find_symbol_in_baseclass (base_type, name, block);
+ if (sym != NULL)
+ break;
+ }
+ }
+
+ do_cleanups (cleanup);
+ return sym;
+}
+
+/* Look up a symbol named NESTED_NAME that is nested inside the C++