mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-11 14:07:27 +08:00
class.c (currently_open_class): New fn.
* class.c (currently_open_class): New fn. * decl.c (lookup_name_real): Use it. * search.c (lookup_field): Likewise. From-SVN: r19650
This commit is contained in:
parent
6e940d05f4
commit
b9082e8adb
@ -1,4 +1,10 @@
|
||||
Mon Apr 27 07:17:38 1998 Martin von Loewis <loewis@informatik.hu-berlin.de>
|
||||
Sat May 9 14:44:37 1998 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* class.c (currently_open_class): New fn.
|
||||
* decl.c (lookup_name_real): Use it.
|
||||
* search.c (lookup_field): Likewise.
|
||||
|
||||
Fri May 8 23:32:42 1998 Martin von Loewis <loewis@informatik.hu-berlin.de>
|
||||
|
||||
* cp-tree.def (OVERLOAD): New node.
|
||||
* cp-tree.h (BINDING_TYPE, SET_IDENTIFIER_GLOBAL_VALUE,
|
||||
|
@ -4822,6 +4822,21 @@ popclass (modify)
|
||||
;
|
||||
}
|
||||
|
||||
/* Returns 1 if current_class_type is either T or a nested type of T. */
|
||||
|
||||
int
|
||||
currently_open_class (t)
|
||||
tree t;
|
||||
{
|
||||
int i;
|
||||
if (t == current_class_type)
|
||||
return 1;
|
||||
for (i = 0; i < current_class_depth; ++i)
|
||||
if (current_class_stack [-i*2 - 1] == t)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* When entering a class scope, all enclosing class scopes' names with
|
||||
static meaning (static variables, static functions, types and enumerators)
|
||||
have to be visible. This recursive function calls pushclass for all
|
||||
|
@ -4826,20 +4826,21 @@ lookup_name_real (name, prefer_type, nonclass)
|
||||
TYPE_DECLs. */
|
||||
classval = lookup_field (current_class_type, name, 0, 1);
|
||||
|
||||
/* Add implicit 'typename' to types from template bases. lookup_field
|
||||
will do this for us. If classval is actually from an enclosing
|
||||
scope, lookup_nested_field will get it for us. */
|
||||
if (processing_template_decl
|
||||
&& classval && TREE_CODE (classval) == TYPE_DECL
|
||||
&& ! currently_open_class (DECL_CONTEXT (classval))
|
||||
&& uses_template_parms (current_class_type)
|
||||
&& ! DECL_ARTIFICIAL (classval))
|
||||
classval = lookup_field (current_class_type, name, 0, 1);
|
||||
|
||||
/* yylex() calls this with -2, since we should never start digging for
|
||||
the nested name at the point where we haven't even, for example,
|
||||
created the COMPONENT_REF or anything like that. */
|
||||
if (classval == NULL_TREE)
|
||||
classval = lookup_nested_field (name, ! yylex);
|
||||
|
||||
/* Add implicit 'typename' to types from template bases. lookup_field
|
||||
will do this for us. */
|
||||
if (processing_template_decl
|
||||
&& classval && TREE_CODE (classval) == TYPE_DECL
|
||||
&& DECL_CONTEXT (classval) != current_class_type
|
||||
&& uses_template_parms (current_class_type)
|
||||
&& ! DECL_ARTIFICIAL (classval))
|
||||
classval = lookup_field (current_class_type, name, 0, 1);
|
||||
}
|
||||
|
||||
if (locval && classval)
|
||||
|
@ -1549,7 +1549,7 @@ lookup_field (xbasetype, name, protect, want_type)
|
||||
if (rval && TREE_CODE (rval) == TYPE_DECL
|
||||
&& ! DECL_ARTIFICIAL (rval)
|
||||
&& processing_template_decl
|
||||
&& BINFO_TYPE (rval_binfo) != current_class_type
|
||||
&& ! currently_open_class (BINFO_TYPE (rval_binfo))
|
||||
&& uses_template_parms (type))
|
||||
{
|
||||
binfo = rval_binfo;
|
||||
@ -1577,14 +1577,14 @@ lookup_nested_field (name, complain)
|
||||
register tree t;
|
||||
|
||||
tree id = NULL_TREE;
|
||||
if (TREE_CHAIN (current_class_type))
|
||||
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 = TREE_CHAIN (current_class_type);
|
||||
for (t = TYPE_MAIN_DECL (current_class_type);
|
||||
t && DECL_CONTEXT (t);
|
||||
t = TREE_CHAIN (DECL_CONTEXT (t)))
|
||||
t = TYPE_MAIN_DECL (DECL_CONTEXT (t)))
|
||||
{
|
||||
if (TREE_CODE (DECL_CONTEXT (t)) != RECORD_TYPE)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user