summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/class.c15
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/cp/search.c8
4 files changed, 35 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 887026dd07b..0006972b434 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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,
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index fe5b8614206..0e3e3cde124 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c73bea15111..d0afbc2791e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4826,20 +4826,21 @@ lookup_name_real (name, prefer_type, nonclass)
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)
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index bbcf40c3cee..08291a892a3 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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;