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

--- Comment #4 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:e32869a17b788bee9ca782b174a546b1db17b5ea

commit r12-7563-ge32869a17b788bee9ca782b174a546b1db17b5ea
Author: Patrick Palka <ppa...@redhat.com>
Date:   Wed Mar 9 08:42:32 2022 -0500

    c++: detecting copy-init context during CTAD [PR102137]

    Here we're failing to communicate to cp_finish_decl from tsubst_expr
    that we're in a copy-initialization context (via the LOOKUP_ONLYCONVERTING
    flag), which causes us to always consider explicit deduction guides when
    performing CTAD for a templated variable initializer.

    It turns out this bug also affects consideration of explicit conversion
    operators for the same reason.  But consideration of explicit constructors
    seems unaffacted thanks to code in build_aggr_init that sets
    LOOKUP_ONLYCONVERTING when the initializer represents copy-initialization.

    So this patch fixes this by making cp_finish_decl set LOOKUP_ONLYCONVERTING
    just like build_aggr_init does, by inspecting the initializer, so that
    callers don't need to explicitly pass this flag appropriately.

            PR c++/102137
            PR c++/87820

    gcc/cp/ChangeLog:

            * cp-tree.h (is_copy_initialization): Declare.
            * decl.cc (cp_finish_decl): Set LOOKUP_ONLYCONVERTING
            when is_copy_initialization is true.
            * init.cc (build_aggr_init): Split out copy-initialization
            check into ...
            (is_copy_initialization): ... here.
            * pt.cc (instantiate_decl): Pass 0 instead of
            LOOKUP_ONLYCONVERTING as flags to cp_finish_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/explicit15.C: New test.
            * g++.dg/cpp1z/class-deduction108.C: New test.
  • [Bug c++/87820] Explicit user-d... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to