On Wed, Nov 29, 2023 at 01:58:31PM -0500, Jason Merrill wrote: > On 11/29/23 10:45, Marek Polacek wrote: > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > Now that I'm posting this patch, I think you'll probably want me to use > > ba_any unconditionally. That works too; g++.dg/tc1/dr52.C just needs > > a trivial testsuite tweak: > > 'C' is not an accessible base of 'X' > > v. > > 'C' is an inaccessible base of 'X' > > We should probably unify those messages... > > Hmm, won't using ba_any unconditionally break ambiguous base checking for > non-static data members?
Yes. I thought not but that's only because we weren't properly testing that case (added scoped14.C, patch to follow). So that settles that. > > @@ -3493,9 +3493,24 @@ finish_class_member_access_expr (cp_expr object, > > tree name, bool template_p, > > return error_mark_node; > > } > > + /* NAME may refer to a static data member, in which case there is > > + one copy of the data member that is shared by all the objects of > > + the class. So NAME can be unambiguously referred to even if > > + there are multiple indirect base classes containing NAME. */ > > + const base_access ba = [scope, name] () > > Why a lambda? Only so that I can set 'ba' once and make it const. I don't believe it deserves a named function. It seems more readable than using a ?:. > > + { > > + if (identifier_p (name)) > > + { > > + tree m = lookup_member (scope, name, /*protect=*/0, > > + /*want_type=*/false, tf_none); > > + if (!m || VAR_P (m)) > > Do you want shared_member_p here? That looks like the right thing to use, thanks. Marek