cp-tree.h (lookup_nested_field): Remove.
authorMark Mitchell <mark@codesourcery.com>
Thu, 15 Apr 1999 19:21:21 +0000 (19:21 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 15 Apr 1999 19:21:21 +0000 (19:21 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/search.c
gcc/testsuite/g++.old-deja/g++.other/lookup14.C [new file with mode: 0644]

index 9429875e8524e9d15a936d7e65fa953ea5b4cd4c..cdcb7b574578fb16d99bf5c57f6f219b9cba940a 100644 (file)
@@ -1,5 +1,13 @@
 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.
        * decl2.c (handle_class_head): Create template declarations here,
        as appropriate.
index 0df7470d5084d558e8ade4dd9d0c6421b9bbc61e..4d970f5d6f2f91c44a264d7ebaa823c1518277df 100644 (file)
@@ -4617,7 +4617,7 @@ push_nested_class (type, modify)
   
   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);
   pushclass (type, modify);
 }
@@ -4630,7 +4630,7 @@ pop_nested_class ()
   tree context = DECL_CONTEXT (TYPE_MAIN_DECL (current_class_type));
 
   popclass ();
-  if (context && TREE_CODE (context) == RECORD_TYPE)
+  if (context && CLASS_TYPE_P (context))
     pop_nested_class ();
 }
 
index a7d27ac9a692d7ec70356c915c3eb643d2e972c7..dcfdeb380212e111a946dd9a79063dccf2d57488 100644 (file)
@@ -3189,7 +3189,6 @@ extern tree get_binfo                             PROTO((tree, tree, int));
 extern int get_base_distance                   PROTO((tree, tree, int, tree *));
 extern int accessible_p                         PROTO((tree, tree));
 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 tree lookup_fnfields                    PROTO((tree, tree, int));
 extern tree lookup_member                      PROTO((tree, tree, int, int));
index e1e63aefdaac3ba92ee020f1003876ab512d2cc4..163c3d75ef7e272e8ba19bfea353d6ec5386c9b3 100644 (file)
@@ -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
      implicit typename extension) make sure that there's not some
      global name which should be chosen instead.  */
@@ -7135,7 +7131,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
 
   if (context && TYPE_SIZE (complete_type (context)) != NULL_TREE)
     {
-      pushclass (context, 2);
+      push_nested_class (context, 2);
 
       if (TREE_CODE (decl) == VAR_DECL)
        {
@@ -8176,7 +8172,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
               the binding level..  */
            && TYPE_SIZE (context) != NULL_TREE
            && context == current_class_type)
-         popclass ();
+         pop_nested_class ();
       }
     }
 
index a756acde93eacf61d6018a4f994b6fea96bcb858..c061d72dca60e7787a64bb03fe4e58debc0acac4 100644 (file)
@@ -1485,70 +1485,6 @@ lookup_fnfields (xbasetype, name, protect)
   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
    the method vector with name NAME, or -1 is no such field exists.  */
 
diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup14.C b/gcc/testsuite/g++.old-deja/g++.other/lookup14.C
new file mode 100644 (file)
index 0000000..5c81c44
--- /dev/null
@@ -0,0 +1,14 @@
+// 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;
+}