]> gcc.gnu.org Git - gcc.git/commit
c++: non-static memfn call dependence cleanup [PR106086]
authorPatrick Palka <ppalka@redhat.com>
Fri, 20 Oct 2023 14:50:19 +0000 (10:50 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 20 Oct 2023 14:50:19 +0000 (10:50 -0400)
commit909672f02ff75a6a94c88dee4aa41e92edb1d1ed
tree5d586e5a4604b078e2f8630ef3729ba1bdff3513
parentcd0e05b7ac3dee11287078acd00a19e52a738963
c++: non-static memfn call dependence cleanup [PR106086]

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.
gcc/cp/parser.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp1y/lambda-generic-this5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash127.C
This page took 0.058263 seconds and 5 git commands to generate.