Commit 6b400b21 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (lookup_nested_field): Remove.

	* cp-tree.h (lookup_nested_field): Remove.
	* class.c (push_nested_class): Handle UNION_TYPEs.
	(pop_nested_class): Likewise.
	* decl.c (lookup_name_real): Don't call lookup_nested_field.
	(start_decl): Use push_nested_class, not just pushclass.
	(cp_finish_decl): Use pop_nested_class, not just popclass.
	* search.c (lookup_nested_field): Remove.

From-SVN: r26476
parent 3d7de1fa
1999-04-15 Mark Mitchell <mark@codesourcery.com> 1999-04-15 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lookup_nested_field): Remove.
* class.c (push_nested_class): Handle UNION_TYPEs.
(pop_nested_class): Likewise.
* decl.c (lookup_name_real): Don't call lookup_nested_field.
(start_decl): Use push_nested_class, not just pushclass.
(cp_finish_decl): Use pop_nested_class, not just popclass.
* search.c (lookup_nested_field): Remove.
* cp-tree.h (lang_type): Add documentation. * cp-tree.h (lang_type): Add documentation.
* decl2.c (handle_class_head): Create template declarations here, * decl2.c (handle_class_head): Create template declarations here,
as appropriate. as appropriate.
......
...@@ -4617,7 +4617,7 @@ push_nested_class (type, modify) ...@@ -4617,7 +4617,7 @@ push_nested_class (type, modify)
context = DECL_CONTEXT (TYPE_MAIN_DECL (type)); context = DECL_CONTEXT (TYPE_MAIN_DECL (type));
if (context && TREE_CODE (context) == RECORD_TYPE) if (context && CLASS_TYPE_P (context))
push_nested_class (context, 2); push_nested_class (context, 2);
pushclass (type, modify); pushclass (type, modify);
} }
...@@ -4630,7 +4630,7 @@ pop_nested_class () ...@@ -4630,7 +4630,7 @@ pop_nested_class ()
tree context = DECL_CONTEXT (TYPE_MAIN_DECL (current_class_type)); tree context = DECL_CONTEXT (TYPE_MAIN_DECL (current_class_type));
popclass (); popclass ();
if (context && TREE_CODE (context) == RECORD_TYPE) if (context && CLASS_TYPE_P (context))
pop_nested_class (); pop_nested_class ();
} }
......
...@@ -3189,7 +3189,6 @@ extern tree get_binfo PROTO((tree, tree, int)); ...@@ -3189,7 +3189,6 @@ extern tree get_binfo PROTO((tree, tree, int));
extern int get_base_distance PROTO((tree, tree, int, tree *)); extern int get_base_distance PROTO((tree, tree, int, tree *));
extern int accessible_p PROTO((tree, tree)); extern int accessible_p PROTO((tree, tree));
extern tree lookup_field PROTO((tree, tree, int, int)); extern tree lookup_field PROTO((tree, tree, int, int));
extern tree lookup_nested_field PROTO((tree, int));
extern int lookup_fnfields_1 PROTO((tree, tree)); extern int lookup_fnfields_1 PROTO((tree, tree));
extern tree lookup_fnfields PROTO((tree, tree, int)); extern tree lookup_fnfields PROTO((tree, tree, int));
extern tree lookup_member PROTO((tree, tree, int, int)); extern tree lookup_member PROTO((tree, tree, int, int));
......
...@@ -5643,10 +5643,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) ...@@ -5643,10 +5643,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
} }
} }
/* The name might be from an enclosing class of the current scope. */
if (!val && !nonclass && current_class_type)
val = qualify_lookup (lookup_nested_field (name, !yylex), flags);
/* If we found a type from a dependent base class (using the /* If we found a type from a dependent base class (using the
implicit typename extension) make sure that there's not some implicit typename extension) make sure that there's not some
global name which should be chosen instead. */ global name which should be chosen instead. */
...@@ -7135,7 +7131,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) ...@@ -7135,7 +7131,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
if (context && TYPE_SIZE (complete_type (context)) != NULL_TREE) if (context && TYPE_SIZE (complete_type (context)) != NULL_TREE)
{ {
pushclass (context, 2); push_nested_class (context, 2);
if (TREE_CODE (decl) == VAR_DECL) if (TREE_CODE (decl) == VAR_DECL)
{ {
...@@ -8176,7 +8172,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -8176,7 +8172,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
the binding level.. */ the binding level.. */
&& TYPE_SIZE (context) != NULL_TREE && TYPE_SIZE (context) != NULL_TREE
&& context == current_class_type) && context == current_class_type)
popclass (); pop_nested_class ();
} }
} }
......
...@@ -1485,70 +1485,6 @@ lookup_fnfields (xbasetype, name, protect) ...@@ -1485,70 +1485,6 @@ lookup_fnfields (xbasetype, name, protect)
return rval; return rval;
} }
/* Try to find NAME inside a nested class. */
tree
lookup_nested_field (name, complain)
tree name;
int complain;
{
register tree t;
tree id = NULL_TREE;
if (TYPE_MAIN_DECL (current_class_type))
{
/* Climb our way up the nested ladder, seeing if we're trying to
modify a field in an enclosing class. If so, we should only
be able to modify if it's static. */
for (t = TYPE_MAIN_DECL (current_class_type);
t && DECL_CONTEXT (t);
t = TYPE_MAIN_DECL (DECL_CONTEXT (t)))
{
if (TREE_CODE (DECL_CONTEXT (t)) != RECORD_TYPE)
break;
/* N.B.: lookup_field will do the access checking for us */
id = lookup_field (DECL_CONTEXT (t), name, complain, 0);
if (id == error_mark_node)
{
id = NULL_TREE;
continue;
}
if (id != NULL_TREE)
{
if (TREE_CODE (id) == FIELD_DECL
&& ! TREE_STATIC (id)
&& TREE_TYPE (id) != error_mark_node)
{
if (complain)
{
/* At parse time, we don't want to give this error, since
we won't have enough state to make this kind of
decision properly. But there are times (e.g., with
enums in nested classes) when we do need to call
this fn at parse time. So, in those cases, we pass
complain as a 0 and just return a NULL_TREE. */
cp_error ("assignment to non-static member `%D' of enclosing class `%T'",
id, DECL_CONTEXT (t));
/* Mark this for do_identifier(). It would otherwise
claim that the variable was undeclared. */
TREE_TYPE (id) = error_mark_node;
}
else
{
id = NULL_TREE;
continue;
}
}
break;
}
}
}
return id;
}
/* TYPE is a class type. Return the index of the fields within /* TYPE is a class type. Return the index of the fields within
the method vector with name NAME, or -1 is no such field exists. */ the method vector with name NAME, or -1 is no such field exists. */
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
union U {
typedef int I;
struct S {
void f();
};
};
void U::S::f() {
I i;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment