diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-07-23 21:28:24 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-07-23 21:28:24 +0000 |
commit | bd16cb258ee3cf903c488b162b7cd479c12feb7c (patch) | |
tree | 9f2a2970cd70097047c205b2cf2c52e242f3e23d /gcc/cp/search.c | |
parent | ff89cb01b7f1367a71be2b5df30c0768b20b2da8 (diff) | |
download | gcc-bd16cb258ee3cf903c488b162b7cd479c12feb7c.tar.gz |
re PR c++/11645 (Failure to deal with using and private inheritance)
PR c++/11645
* cp-tree.h (accessible_base_p): Declare.
* call.c (build_over_call): Use it.
* search.c (accessible_base_p): New function, split out from ...
(lookup_base): ... here.
PR c++/11645
* g++.dg/inherit/access4.C: New test.
From-SVN: r69724
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r-- | gcc/cp/search.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 10b52164cd0..3f8e2daf8a8 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -231,6 +231,28 @@ lookup_base_r (tree binfo, tree base, base_access access, return found; } +/* Returns true if type BASE is accessible in T. (BASE is known to be + a base class of T.) */ + +bool +accessible_base_p (tree t, tree base) +{ + tree decl; + + /* [class.access.base] + + A base class is said to be accessible if an invented public + member of the base class is accessible. */ + /* Rather than inventing a public member, we use the implicit + public typedef created in the scope of every class. */ + decl = TYPE_FIELDS (base); + while (!DECL_SELF_REFERENCE_P (decl)) + decl = TREE_CHAIN (decl); + while (ANON_AGGR_TYPE_P (t)) + t = TYPE_CONTEXT (t); + return accessible_p (t, decl); +} + /* Lookup BASE in the hierarchy dominated by T. Do access checking as ACCESS specifies. Return the binfo we discover. If KIND_PTR is non-NULL, fill with information about what kind of base we @@ -287,39 +309,24 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr) break; default: - if (access != ba_ignore + if ((access & ~ba_quiet) != ba_ignore /* 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, there's no need to issue another error here, and there's no implicit typedef to use in the code that follows, so we skip the check. */ - && COMPLETE_TYPE_P (base)) + && COMPLETE_TYPE_P (base) + && !accessible_base_p (t, base)) { - tree decl; - - /* [class.access.base] - - A base class is said to be accessible if an invented public - member of the base class is accessible. */ - /* Rather than inventing a public member, we use the implicit - public typedef created in the scope of every class. */ - decl = TYPE_FIELDS (base); - while (!DECL_SELF_REFERENCE_P (decl)) - decl = TREE_CHAIN (decl); - while (ANON_AGGR_TYPE_P (t)) - t = TYPE_CONTEXT (t); - if (!accessible_p (t, decl)) + if (!(access & ba_quiet)) { - if (!(access & ba_quiet)) - { - error ("`%T' is an inaccessible base of `%T'", base, t); - binfo = error_mark_node; - } - else - binfo = NULL_TREE; - bk = bk_inaccessible; + error ("`%T' is an inaccessible base of `%T'", base, t); + binfo = error_mark_node; } + else + binfo = NULL_TREE; + bk = bk_inaccessible; } break; } |