mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 12:00:11 -05:00
In cp_parser_postfix_expression, and in the CALL_EXPR case of tsubst_copy_and_build, we essentially repeat the type-dependent and COMPONENT_REF callee cases of finish_call_expr. This patch deduplicates this logic by making both spots consistently go through finish_call_expr. This allows us to easily fix PR106086 -- which is about us neglecting to capture 'this' when we resolve a use of a non-static member function of the current instantiation only at lambda regeneration time -- by moving the call to maybe_generic_this_capture from the parser to finish_call_expr so that we consider capturing 'this' at regeneration time as well. PR c++/106086 gcc/cp/ChangeLog: * parser.cc (cp_parser_postfix_expression): Consolidate three calls to finish_call_expr, one to build_new_method_call and one to build_min_nt_call_vec into one call to finish_call_expr. Don't call maybe_generic_this_capture here. * pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Remove COMPONENT_REF callee handling. (type_dependent_expression_p): Use t_d_object_e_p instead of t_d_e_p for COMPONENT_REF and OFFSET_REF. * semantics.cc (finish_call_expr): In the type-dependent case, call maybe_generic_this_capture here instead. gcc/testsuite/ChangeLog: * g++.dg/template/crash127.C: Expect additional error due to being able to check the member access expression ahead of time. Strengthen the test by not instantiating the class template. * g++.dg/cpp1y/lambda-generic-this5.C: New test.
23 lines
419 B
C
23 lines
419 B
C
// PR c++/106086
|
|
// { dg-do compile { target c++14 } }
|
|
|
|
template<class T>
|
|
struct A {
|
|
void f(int) const;
|
|
static void g(int);
|
|
};
|
|
|
|
template<class T>
|
|
struct B : A<T> {
|
|
auto f() const {
|
|
auto l1 = [&](auto x) { A<T>::f(x); };
|
|
auto l2 = [&](auto x) { A<T>::g(x); };
|
|
static_assert(sizeof(l1) == sizeof(this), "");
|
|
static_assert(sizeof(l2) == 1, "");
|
|
l1(0);
|
|
l2(0);
|
|
}
|
|
};
|
|
|
|
template struct B<void>;
|