* class.c (currently_open_class): New fn.
* decl.c (lookup_name_real): Use it.
* search.c (lookup_field): Likewise.
From-SVN: r19650
-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,
;
}
+/* 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
TYPE_DECLs. */
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. */
+ 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
- && DECL_CONTEXT (classval) != current_class_type
+ && ! 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);
}
if (locval && classval)
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;
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;