+2006-01-18 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/25836
+ * cp-tree.h (push_class_stack): New function.
+ (pop_class_stack): Likewise.
+ * class.c (class_stack_node): Add hidden field.
+ (pushclass): Clear it.
+ (push_class_stack): New function.
+ (pop_class_stack): Likewise.
+ (currently_open_class): Ignore hidden classes.
+ (currently_open_derived_class): Likewise.
+ * name-lookup.c (push_to_top_level): Call push_class_stack.
+ (pop_from_top_level): Call pop_class_stack.
+
2006-01-18 Kazu Hirata <kazu@codesourcery.com>
* tree.c (find_tree_t, find_tree): Remove.
/* If were defining TYPE, the names used in this class. */
splay_tree names_used;
+
+ /* Nonzero if this class is no longer open, because of a call to
+ push_to_top_level. */
+ size_t hidden;
}* class_stack_node_t;
typedef struct vtbl_init_data_s
void
pushclass (tree type)
{
+ class_stack_node_t csn;
+
type = TYPE_MAIN_VARIANT (type);
/* Make sure there is enough room for the new entry on the stack. */
}
/* Insert a new entry on the class stack. */
- current_class_stack[current_class_depth].name = current_class_name;
- current_class_stack[current_class_depth].type = current_class_type;
- current_class_stack[current_class_depth].access = current_access_specifier;
- current_class_stack[current_class_depth].names_used = 0;
+ csn = current_class_stack + current_class_depth;
+ csn->name = current_class_name;
+ csn->type = current_class_type;
+ csn->access = current_access_specifier;
+ csn->names_used = 0;
+ csn->hidden = 0;
current_class_depth++;
/* Now set up the new type. */
splay_tree_delete (current_class_stack[current_class_depth].names_used);
}
+/* Mark the top of the class stack as hidden. */
+
+void
+push_class_stack (void)
+{
+ if (current_class_depth)
+ ++current_class_stack[current_class_depth - 1].hidden;
+}
+
+/* Mark the top of the class stack as un-hidden. */
+
+void
+pop_class_stack (void)
+{
+ if (current_class_depth)
+ --current_class_stack[current_class_depth - 1].hidden;
+}
+
/* Returns 1 if current_class_type is either T or a nested type of T.
We start looking from 1 because entry 0 is from global scope, and has
no type. */
int i;
if (current_class_type && same_type_p (t, current_class_type))
return 1;
- for (i = 1; i < current_class_depth; ++i)
- if (current_class_stack[i].type
- && same_type_p (current_class_stack [i].type, t))
- return 1;
+ for (i = current_class_depth - 1; i > 0; --i)
+ {
+ if (current_class_stack[i].hidden)
+ break;
+ if (current_class_stack[i].type
+ && same_type_p (current_class_stack [i].type, t))
+ return 1;
+ }
return 0;
}
return current_class_type;
for (i = current_class_depth - 1; i > 0; --i)
- if (DERIVED_FROM_P (t, current_class_stack[i].type))
- return current_class_stack[i].type;
+ {
+ if (current_class_stack[i].hidden)
+ break;
+ if (DERIVED_FROM_P (t, current_class_stack[i].type))
+ return current_class_stack[i].type;
+ }
return NULL_TREE;
}
extern void set_linkage_according_to_type (tree, tree);
extern void determine_key_method (tree);
extern void check_for_override (tree, tree);
+extern void push_class_stack (void);
+extern void pop_class_stack (void);
/* in cvt.c */
extern tree convert_to_reference (tree, tree, int, int, tree);