]> gcc.gnu.org Git - gcc.git/commit
c++: function NTTP argument considered unused [PR53164, PR105848]
authorPatrick Palka <ppalka@redhat.com>
Mon, 6 Jun 2022 18:29:12 +0000 (14:29 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 21 Jul 2022 16:38:46 +0000 (12:38 -0400)
commit670ef5b108d0acfbde96f44b064079f2fa0c92d4
tree7efd087aa812013f0c27a96963d2c001df71f845
parent41487bff13fa98607ab5548bc1a0dca71147a5ac
c++: function NTTP argument considered unused [PR53164, PR105848]

Here at parse time the template argument f (an OVERLOAD) in A<f> gets
resolved ahead of time to the FUNCTION_DECL f<int>, and we defer marking
f<int> as used until instantiation (of g) as usual.

Later when instantiating g the type A<f> (where f has already been
resolved) is non-dependent, so tsubst_aggr_type avoids re-processing its
template arguments, and we end up never actually marking f<int> as used
(which means we never instantiate it) even though A<f>::h() later calls
it, leading to a link error.

This patch works around this issue by looking through ADDR_EXPR when
calling mark_used on the substituted callee of a CALL_EXPR.

PR c++/53164
PR c++/105848

gcc/cp/ChangeLog:

* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Look through an
ADDR_EXPR callee when calling mark_used.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr3.C: New test.

(cherry picked from commit 733a792a2b2e1662e738fa358b45a2720a8618a7)
gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/fn-ptr3.C [new file with mode: 0644]
This page took 0.065201 seconds and 5 git commands to generate.