-/* Subroutines of push_class_decls (). */
-
-static void
-setup_class_bindings (tree name, int type_binding_p)
-{
- tree type_binding = NULL_TREE;
- tree value_binding;
-
- /* If we've already done the lookup for this declaration, we're
- done. */
- if (IDENTIFIER_CLASS_VALUE (name))
- return;
-
- /* First, deal with the type binding. */
- if (type_binding_p)
- {
- type_binding = lookup_member (current_class_type, name,
- /*protect=*/2, /*want_type=*/true);
- if (TREE_CODE (type_binding) == TREE_LIST
- && TREE_TYPE (type_binding) == error_mark_node)
- /* NAME is ambiguous. */
- push_class_level_binding (name, type_binding);
- else
- pushdecl_class_level (type_binding);
- }
-
- /* Now, do the value binding. */
- value_binding = lookup_member (current_class_type, name,
- /*protect=*/2, /*want_type=*/false);
-
- if (type_binding_p
- && (TREE_CODE (value_binding) == TYPE_DECL
- || DECL_CLASS_TEMPLATE_P (value_binding)
- || (TREE_CODE (value_binding) == TREE_LIST
- && TREE_TYPE (value_binding) == error_mark_node
- && (TREE_CODE (TREE_VALUE (value_binding))
- == TYPE_DECL))))
- /* We found a type-binding, even when looking for a non-type
- binding. This means that we already processed this binding
- above. */;
- else if (value_binding)
- {
- if (TREE_CODE (value_binding) == TREE_LIST
- && TREE_TYPE (value_binding) == error_mark_node)
- /* NAME is ambiguous. */
- push_class_level_binding (name, value_binding);
- else
- {
- if (BASELINK_P (value_binding))
- /* NAME is some overloaded functions. */
- value_binding = BASELINK_FUNCTIONS (value_binding);
- /* Two conversion operators that convert to the same type
- may have different names. (See
- mangle_conv_op_name_for_type.) To avoid recording the
- same conversion operator declaration more than once we
- must check to see that the same operator was not already
- found under another name. */
- if (IDENTIFIER_TYPENAME_P (name)
- && is_overloaded_fn (value_binding))
- {
- tree fns;
- for (fns = value_binding; fns; fns = OVL_NEXT (fns))
- if (IDENTIFIER_CLASS_VALUE (DECL_NAME (OVL_CURRENT (fns))))
- return;
- }
- pushdecl_class_level (value_binding);
- }
- }
-}
-
-/* Push class-level declarations for any names appearing in BINFO that
- are TYPE_DECLS. */
-
-static tree
-dfs_push_type_decls (tree binfo, void *data ATTRIBUTE_UNUSED)
-{
- tree type;
- tree fields;
-
- type = BINFO_TYPE (binfo);
- for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
- if (DECL_NAME (fields) && TREE_CODE (fields) == TYPE_DECL
- && !(!same_type_p (type, current_class_type)
- && template_self_reference_p (type, fields)))
- setup_class_bindings (DECL_NAME (fields), /*type_binding_p=*/1);
-
- /* We can't just use BINFO_MARKED because envelope_add_decl uses
- DERIVED_FROM_P, which calls get_base_distance. */
- BINFO_PUSHDECLS_MARKED (binfo) = 1;
-
- return NULL_TREE;
-}
-
-/* Push class-level declarations for any names appearing in BINFO that
- are not TYPE_DECLS. */
-
-static tree
-dfs_push_decls (tree binfo, void *data)
-{
- tree type = BINFO_TYPE (binfo);
- tree method_vec;
- tree fields;
-
- for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
- if (DECL_NAME (fields)
- && TREE_CODE (fields) != TYPE_DECL
- && TREE_CODE (fields) != USING_DECL
- && !DECL_ARTIFICIAL (fields))
- setup_class_bindings (DECL_NAME (fields), /*type_binding_p=*/0);
- else if (TREE_CODE (fields) == FIELD_DECL
- && ANON_AGGR_TYPE_P (TREE_TYPE (fields)))
- dfs_push_decls (TYPE_BINFO (TREE_TYPE (fields)), data);
-
- method_vec = (CLASS_TYPE_P (type)
- ? CLASSTYPE_METHOD_VEC (type) : NULL_TREE);
-
- if (method_vec && TREE_VEC_LENGTH (method_vec) >= 3)
- {
- tree *methods;
- tree *end;
-
- /* Farm out constructors and destructors. */
- end = TREE_VEC_END (method_vec);
-
- for (methods = &TREE_VEC_ELT (method_vec, 2);
- methods < end && *methods;
- methods++)
- setup_class_bindings (DECL_NAME (OVL_CURRENT (*methods)),
- /*type_binding_p=*/0);
- }
-
- BINFO_PUSHDECLS_MARKED (binfo) = 0;
-
- return NULL_TREE;
-}
-
-/* When entering the scope of a class, we cache all of the
- fields that that class provides within its inheritance
- lattice. Where ambiguities result, we mark them
- with `error_mark_node' so that if they are encountered
- without explicit qualification, we can emit an error
- message. */
-
-void
-push_class_decls (tree type)
-{
- search_stack = push_search_level (search_stack, &search_obstack);
-
- /* Enter type declarations and mark. */
- dfs_walk (TYPE_BINFO (type), dfs_push_type_decls, unmarked_pushdecls_p, 0);
-
- /* Enter non-type declarations and unmark. */
- dfs_walk (TYPE_BINFO (type), dfs_push_decls, marked_pushdecls_p, 0);
-}
-
-/* Here's a subroutine we need because C lacks lambdas. */
-
-static tree
-dfs_unuse_fields (tree binfo, void *data ATTRIBUTE_UNUSED)
-{
- tree type = TREE_TYPE (binfo);
- tree fields;
-
- for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
- {
- if (TREE_CODE (fields) != FIELD_DECL || DECL_ARTIFICIAL (fields))
- continue;
-
- TREE_USED (fields) = 0;
- if (DECL_NAME (fields) == NULL_TREE
- && ANON_AGGR_TYPE_P (TREE_TYPE (fields)))
- unuse_fields (TREE_TYPE (fields));
- }
-
- return NULL_TREE;
-}
-