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

--- Comment #6 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:682d401a6ba723b2bf98779d056efc8ff2640178

commit r14-1697-g682d401a6ba723b2bf98779d056efc8ff2640178
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sun Jun 11 11:09:16 2023 -0400

    c++: extend lookup_template_class shortcut [PR110122]

    Here when substituting the injected class name A during regeneration of
    the lambda, we find ourselves in lookup_template_class for A<V> with
    V=_ZTAXtl3BarEE (i.e. the template parameter object for Foo{}).  The call
    to coerce_template_parms within then undesirably tries to make a copy of
    this class NTTP argument, which fails because Foo is not copyable.  But it
    seems clear that this testcase shouldn't require copyability of Foo.

    lookup_template_class has a shortcut for looking up the current class
    scope, which would avoid the problematic coerce_template_parms call, but
    the shortcut doesn't trigger because it only considers the innermost
    class scope which in this case in the lambda type.  So this patch fixes
    this by extending the lookup_template_class shortcut to consider outer
    class scopes too (and skipping over lambda types since they are never
    specialized from lookup_template_class).  We also need to avoid calling
    coerce_template_parms when specializing a templated non-template nested
    class for the first time (such as A::B in the testcase).  Coercion should
    be unnecessary there because the innermost arguments belong to the context
    and so should have already been coerced.

            PR c++/110122

    gcc/cp/ChangeLog:

            * pt.cc (lookup_template_class): Extend shortcut for looking up the
            current class scope to consider outer class scopes too, and use
            current_nonlambda_class_type instead of current_class_type.  Only
            call coerce_template_parms when specializing a primary template.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/nontype-class57.C: New test.
            * g++.dg/cpp2a/nontype-class58.C: New test.

Reply via email to