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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>:

https://gcc.gnu.org/g:30c811f2bac73e63e0b461ba7ed3805b77898798

commit r13-2550-g30c811f2bac73e63e0b461ba7ed3805b77898798
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Sep 6 13:21:09 2022 +0100

    c++: Fix type completeness checks for type traits [PR106838]

    The check_trait_type function is used for a number of different type
    traits that have different requirements on their arguments. For example,
    __is_constructible allows arrays of unknown bound even if the array
    element is an incomplete type, but __is_aggregate does not, it always
    requires the array element type to be complete. Other traits have
    different requirements again, e.g. __is_empty allows incomplete unions,
    and arrays (of known or unknown bound) of incomplete types.

    This alters the check_trait_type function to take an additional KIND
    parameter which indicates which set of type trait requirements to check.

    As noted in a comment, the requirements for __is_aggregate deviate from
    the ones for std::is_aggregate in the standard. It's not necessary for
    the elements of an array to be complete types, because arrays are always
    aggregates.

    The type_has_virtual_destructor change is needed to avoid an ICE.
    Previously it could never be called for incomplete union types as they
    were (incorrectly) rejected by check_trait_type.

    This change causes some additional diagnostics in some libstdc++ tests,
    where the front end was not previously complaining about invalid types
    that the library assertions diagnosed. We should consider removing the
    library assertions from traits where the front end implements the
    correct checks now.

            PR c++/106838

    gcc/cp/ChangeLog:

            * class.cc (type_has_virtual_destructor): Return false for
            union types.
            * semantics.cc (check_trait_type): Add KIND parameter to support
            different sets of requirements.
            (finish_trait_expr): Pass KIND argument for relevant traits.

    gcc/ChangeLog:

            * doc/extend.texi (Type Traits): Fix requirements. Document
            __is_aggregate and __is_final.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/array4.C: Fix invalid use of __is_constructible.
            * g++.dg/ext/unary_trait_incomplete.C: Fix tests for traits with
            different requirements.

    libstdc++-v3/ChangeLog:

            * testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
            Prune additional errors from front-end.
            * testsuite/20_util/is_move_constructible/incomplete_neg.cc:
            Likewise.
            * testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc:
            Likewise.
            * testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc:
            Likewise.
            * testsuite/20_util/is_swappable_with/incomplete_neg.cc:
            Likewise.

Reply via email to