https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105848

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:733a792a2b2e1662e738fa358b45a2720a8618a7

commit r13-995-g733a792a2b2e1662e738fa358b45a2720a8618a7
Author: Patrick Palka <ppa...@redhat.com>
Date:   Mon Jun 6 14:29:12 2022 -0400

    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.

Reply via email to