diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2004-10-18 17:21:36 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2004-10-18 17:21:36 +0000 |
commit | 18e4be8561b8aee3937528dd27635eaf761e57d0 (patch) | |
tree | 236c7f936b34023b8a9d3dac4bda50d439059160 /gcc/cp/search.c | |
parent | b499264121070eb0876ab645d34bea38493c1821 (diff) | |
download | gcc-18e4be8561b8aee3937528dd27635eaf761e57d0.zip gcc-18e4be8561b8aee3937528dd27635eaf761e57d0.tar.gz gcc-18e4be8561b8aee3937528dd27635eaf761e57d0.tar.bz2 |
cp-tree.h (UNIQUELY_DERIVED_FROM_P): Adjust lookup_base call.
cp:
* cp-tree.h (UNIQUELY_DERIVED_FROM_P): Adjust lookup_base call.
(ACCESSIBLY_UNIQUELY_DERIVED_P): Remove.
(PUBLICLY_UNIQUELY_DERIVED_P): Adjust lookup_base call.
(enum base_access): Reorganize.
(accessible_base_p, accessible_p): Add consider_local_p parameter.
* call.c (standard_conversion): Update comment about
DERIVED_FROM_P.
(enforce_access): Adjust accessible_p call.
(build_over_call): Adjust accessible_base_p call.
* class.c (convert_to_base): Adjust lookup_base call.
(build_vtbl_ref_1): Likewise.
(warn_about_ambiguous_bases): Likewise. Add early exit.
* cvt.c (convert_to_pointer_force) Adjust lookup_base call.
* search.c (accessible_base_p): Add consider_local_p parameter.
(lookup_base): Pass consider_local_p to accessible_base_p call.
(friend_accessible_p): Check whether scope is a class member.
Remove unnecessary class template check.
(accessible_p): Add consider_local_p parameter. Use it.
(adjust_result_of_qualified_name_lookup): Adjust lookup_base call.
* tree.c (maybe_dummy_object): Likewise.
* typeck.c (comp_except_type): Use PUBLICLY_UNIQUELY_DERIVED_P.
(build_class_member_access_expr): Adjust lookup_base call.
* typeck2.c (binfo_or_else): Likewise.
* rtti.c (build_dynamic_cast_1): Access can consider friendship
and current scope.
testsuite:
* g++.dg/eh/shadow1.C: New.
From-SVN: r89232
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r-- | gcc/cp/search.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 79e0cc3..5b060da5 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -150,10 +150,12 @@ dfs_lookup_base (tree binfo, void *data_) } /* Returns true if type BASE is accessible in T. (BASE is known to be - a (possibly non-proper) base class of T.) */ + a (possibly non-proper) base class of T.) If CONSIDER_LOCAL_P is + true, consider any special access of the current scope, or access + bestowed by friendship. */ bool -accessible_base_p (tree t, tree base) +accessible_base_p (tree t, tree base, bool consider_local_p) { tree decl; @@ -173,7 +175,7 @@ accessible_base_p (tree t, tree base) decl = TREE_CHAIN (decl); while (ANON_AGGR_TYPE_P (t)) t = TYPE_CONTEXT (t); - return accessible_p (t, decl); + return accessible_p (t, decl, consider_local_p); } /* Lookup BASE in the hierarchy dominated by T. Do access checking as @@ -259,7 +261,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr) break; default: - if ((access & ~ba_quiet) != ba_ignore + if ((access & ba_check_bit) /* If BASE is incomplete, then BASE and TYPE are probably the same, in which case BASE is accessible. If they are not the same, then TYPE is invalid. In that case, @@ -267,7 +269,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr) there's no implicit typedef to use in the code that follows, so we skip the check. */ && COMPLETE_TYPE_P (base) - && !accessible_base_p (t, base)) + && !accessible_base_p (t, base, !(access & ba_ignore_scope))) { if (!(access & ba_quiet)) { @@ -806,7 +808,7 @@ friend_accessible_p (tree scope, tree decl, tree binfo) { /* Perhaps this SCOPE is a member of a class which is a friend. */ - if (DECL_CLASS_SCOPE_P (decl) + if (DECL_CLASS_SCOPE_P (scope) && friend_accessible_p (DECL_CONTEXT (scope), decl, binfo)) return 1; @@ -822,16 +824,6 @@ friend_accessible_p (tree scope, tree decl, tree binfo) return ret; } } - else if (CLASSTYPE_TEMPLATE_INFO (scope)) - { - int ret; - /* Increment processing_template_decl to make sure that - dependent_type_p works correctly. */ - ++processing_template_decl; - ret = friend_accessible_p (CLASSTYPE_TI_TEMPLATE (scope), decl, binfo); - --processing_template_decl; - return ret; - } return 0; } @@ -852,13 +844,14 @@ dfs_accessible_post (tree binfo, void *data ATTRIBUTE_UNUSED) class used to name DECL. Return nonzero if, in the current context, DECL is accessible. If TYPE is actually a BINFO node, then we can tell in what context the access is occurring by looking - at the most derived class along the path indicated by BINFO. */ + at the most derived class along the path indicated by BINFO. If + CONSIDER_LOCAL is true, do consider special access the current + scope or friendship thereof we might have. */ int -accessible_p (tree type, tree decl) +accessible_p (tree type, tree decl, bool consider_local_p) { tree binfo; - tree t; tree scope; access_kind access; @@ -910,15 +903,19 @@ accessible_p (tree type, tree decl) We walk the base class hierarchy, checking these conditions. */ - /* Figure out where the reference is occurring. Check to see if - DECL is private or protected in this scope, since that will - determine whether protected access is allowed. */ - if (current_class_type) - protected_ok = protected_accessible_p (decl, current_class_type, binfo); + if (consider_local_p) + { + /* Figure out where the reference is occurring. Check to see if + DECL is private or protected in this scope, since that will + determine whether protected access is allowed. */ + if (current_class_type) + protected_ok = protected_accessible_p (decl, + current_class_type, binfo); - /* Now, loop through the classes of which we are a friend. */ - if (!protected_ok) - protected_ok = friend_accessible_p (scope, decl, binfo); + /* Now, loop through the classes of which we are a friend. */ + if (!protected_ok) + protected_ok = friend_accessible_p (scope, decl, binfo); + } /* Standardize the binfo that access_in_type will use. We don't need to know what path was chosen from this point onwards. */ @@ -930,15 +927,15 @@ accessible_p (tree type, tree decl) if (access == ak_public || (access == ak_protected && protected_ok)) return 1; - else - { - /* Walk the hierarchy again, looking for a base class that allows - access. */ - t = dfs_walk_once_accessible (binfo, /*friends=*/true, - NULL, dfs_accessible_post, NULL); - - return t != NULL_TREE; - } + + if (!consider_local_p) + return 0; + + /* Walk the hierarchy again, looking for a base class that allows + access. */ + return dfs_walk_once_accessible (binfo, /*friends=*/true, + NULL, dfs_accessible_post, NULL) + != NULL_TREE; } struct lookup_field_info { @@ -1486,13 +1483,13 @@ adjust_result_of_qualified_name_lookup (tree decl, or ambiguity -- in either case, the choice of a static member function might make the usage valid. */ base = lookup_base (context_class, qualifying_scope, - ba_ignore | ba_quiet, NULL); + ba_unique | ba_quiet, NULL); if (base) { BASELINK_ACCESS_BINFO (decl) = base; BASELINK_BINFO (decl) = lookup_base (base, BINFO_TYPE (BASELINK_BINFO (decl)), - ba_ignore | ba_quiet, + ba_unique | ba_quiet, NULL); } } |