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

--- Comment #2 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:be124477b38a71ba8ba0b24d859ae764bb44a4eb

commit r13-4729-gbe124477b38a71ba8ba0b24d859ae764bb44a4eb
Author: Patrick Palka <ppa...@redhat.com>
Date:   Thu Dec 15 15:54:31 2022 -0500

    c++: local alias in typename in lambda [PR105518]

    We substitute the qualifying scope of a TYPENAME_TYPE directly using
    tsubst_aggr_type (so that we can pass entering_scope=true) instead of
    going through tsubst, which means we don't properly reuse typedefs
    during this substitution.  This ends up causing us to reject the below
    testcase because we substitute the TYPENAME_TYPE alias::type as if it
    were written without the A<t> alias, and thus we expect the non-capturing
    lambda to capture t.

    This patch fixes this by making tsubst_aggr_type delegate typedefs
    to tsubst so that get consistently reused, and then adjusting the result
    appropriately if entering_scope is true.  In passing, this refactors
    tsubst_aggr_type into two functions, one that's intended to be called
    directly and a more minimal one that's intended to be called only from
    the RECORD/UNION/ENUMERAL_TYPE cases of tsubst (and contains only the
    necessary bits for that call site).

            PR c++/105518

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_aggr_type): Handle typedefs by delegating to
            tsubst and adjusting the result if entering_scope.  Split out
            the main part of the function into ...
            (tsubst_aggr_type_1) ... here.
            (tsubst): Use tsubst_aggr_type_1 instead of tsubst_aggr_type.
            Handle TYPE_PTRMEMFUNC_P RECORD_TYPEs here instead of in
            tsubst_aggr_type_1.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/lambda/lambda-alias1.C: New test.
  • [Bug c++/105518] [rejects valid... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to