From 6b400b21320eff9d60593aab27225e972d167a54 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 15 Apr 1999 19:21:21 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 8 +++ gcc/cp/class.c | 4 +- gcc/cp/cp-tree.h | 1 - gcc/cp/decl.c | 8 +-- gcc/cp/search.c | 64 ------------------- .../g++.old-deja/g++.other/lookup14.C | 14 ++++ 6 files changed, 26 insertions(+), 73 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/lookup14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9429875e852..cdcb7b57457 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 1999-04-15 Mark Mitchell + * 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. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0df7470d508..4d970f5d6f2 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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 (); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a7d27ac9a69..dcfdeb38021 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e1e63aefdaa..163c3d75ef7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 (); } } diff --git a/gcc/cp/search.c b/gcc/cp/search.c index a756acde93e..c061d72dca6 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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 index 00000000000..5c81c44815a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup14.C @@ -0,0 +1,14 @@ +// Build don't link: +// Origin: Mark Mitchell + +union U { + typedef int I; + + struct S { + void f(); + }; +}; + +void U::S::f() { + I i; +} -- 2.30.2