-
- Downloads
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.
Showing
- gcc/cp/call.c 1 addition, 0 deletionsgcc/cp/call.c
- gcc/cp/cp-tree.h 5 additions, 0 deletionsgcc/cp/cp-tree.h
- gcc/cp/pt.c 89 additions, 2 deletionsgcc/cp/pt.c
- gcc/cp/search.c 4 additions, 0 deletionsgcc/cp/search.c
- gcc/testsuite/g++.dg/lookup/memfn1.C 16 additions, 0 deletionsgcc/testsuite/g++.dg/lookup/memfn1.C
- gcc/testsuite/g++.dg/template/non-dependent16b.C 37 additions, 0 deletionsgcc/testsuite/g++.dg/template/non-dependent16b.C
Loading
Please register or sign in to comment