Skip to content
Snippets Groups Projects
Commit ab85331c authored by Patrick Palka's avatar Patrick Palka
Browse files

c++: memfn lookup consistency in incomplete-class ctx

When instantiating a call to a member function of a class template, we
repeat the member function lookup in order to obtain the corresponding
partially instantiated functions.  Within an incomplete-class context
however, we need to be more careful when repeating the lookup because we
don't want to introduce later-declared member functions that weren't
visible at template definition time.  We're currently not careful enough
in this respect, which causes us to reject memfn1.C below.

This patch fixes this issue by making tsubst_baselink filter out from
the instantiation-time lookup those member functions that were invisible
at template definition time.  This is really only necessary within an
incomplete-class context, so this patch adds a heuristic flag to BASELINK
to help us avoid needlessly performing this filtering step (which would
be a no-op) in complete-class contexts.

This is also necessary for the ahead-of-time overload set pruning
implemented in r12-6075 to be effective for member functions within
class templates.

gcc/cp/ChangeLog:

	* call.c (build_new_method_call): Set
	BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P on the pruned baselink.
	* cp-tree.h (BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P): Define.
	* pt.c (filter_memfn_lookup): New subroutine of tsubst_baselink.
	(tsubst_baselink): Use filter_memfn_lookup on the new lookup
	result when BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P is set on the
	old baselink.  Remove redundant BASELINK_P check.
	* search.c (build_baselink): Set
	BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P appropriately.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/memfn1.C: New test.
	* g++.dg/template/non-dependent16b.C: New test.
parent b3f58f87
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment