This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFA: Fix for g++/7874 (friend injection)


Mark Mitchell <mark@codesourcery.com> writes:

> I'm a little unhappy about remove_hidden_names, as that will make
> multiple copies of the same overload set over and over and over again.
> However, you can't rely on a bit on the FUNCTION_DECL itself as early
> users of the function name should not see the declaration, even if later
> users do (because of an explicit namespace-scope declaration).  (This
> matters in templates, for two-phase lookup.)
> 
> The way to fix this is to use a (logical) timestamp; the person holding
> the OVERLOAD should also hold a timestamp indicating when they did the
> lookup.  Then, the FUNCTION_DECL has a timestamp saying at which point
> it became non-hidden.  Then, you can figure out what the really visible
> set of overloads is when you need to use them.

Well, I agree with you, but it also seems to me that that's more or
less true of the whole set of functions under lookup_arg_dependent--
they compute the same overload set again and again.

If we think about adding a timestamp field to FUNCTION_DECL, I think
it would be even easier to add a mark field, and then mark each
visible function using a monotonically increasing mark.  Then
add_function_candidate can ignore any unmarked function.  This also
gives us an easy way to ignore duplicates in add_function as called by
lookup_arg_dependent.  Then we just need a way to avoid the call to
build_overload there....

In any case, I'll put this on my todo list.

> However, I'm not about to ask you to do this now, so patch OK for 4.1.
> I agree that it's inappropriate for 4.0.x.

Committed to mainline.  Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]