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

--- 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:40234200864b6c0d0079abbcdc7a4139b60257ff

commit r11-5799-g40234200864b6c0d0079abbcdc7a4139b60257ff
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Dec 5 13:44:20 2020 -0500

    c++: Normalize nested-requirements twice at parse time [PR97093]

    The re-normalization performed from diagnose_nested_requirement doesn't
    always work because we may have already lost the necessary template
    context that determines the set of in-scope template parameters used by
    the nested-requirement.  This leads to normalization producing atoms
    that have incomplete/bogus parameter mappings, which breaks satisfaction.

    To fix this, we could just use the normal form that we previously
    computed at parse time, but this normal form lacks the diagnostic
    information that leads to good error messages.

    Instead, this patch makes diagnose_nested_requirement normalize twice at
    parse time -- once without diagnostic information and once with -- so
    that routines can use the "regular" normal form when performing
    satisfaction quietly and the "diagnostic" normal form when performing
    satisfaction noisily.  Moreover, this patch makes tsubst_nested_requirement
    always first perform satisfaction quietly so that the satisfaction cache
    can get consistently utilized.

    This patch also adds some sanity checks to build_parameter_mapping that
    would have caught the underlying bug sooner (and deterministically).

    gcc/cp/ChangeLog:

            PR c++/97093
            * constraint.cc (parameter_mapping_equivalent_p): Add some
            sanity checks.  Clarify comment.
            (tsubst_nested_requirement): Always perform satisfaction
            quietly first.  If that yields an erroneous result, emit a
            context message and replay satisfaction noisily with the
            diagnostic normal form.
            (finish_nested_requirement): Normalize the constraint-expression
            twice, once with diagnostic information and once without.  Store
            them in a TREE_LIST within the TREE_TYPE.
            (diagnose_nested_requirement): When replaying satisfaction, use
            the diagnostic normal form instead of renormalizing on the spot.

    gcc/testsuite/ChangeLog:

            PR c++/97093
            * g++.dg/cpp2a/concepts-requires22.C: New test.

Reply via email to