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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:1696fc1ea01d5c9dce96b5d3122921aab9308f59

commit r11-8192-g1696fc1ea01d5c9dce96b5d3122921aab9308f59
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Apr 15 11:37:39 2021 +0100

    c++: Tweak merging of vector attributes that affect type identity [PR98852]

    <arm_neon.h> types are distinct from GNU vector types in at least
    their mangling.  However, there used to be nothing explicit in the
    VECTOR_TYPE itself to indicate the difference: we simply treated them
    as distinct TYPE_MAIN_VARIANTs.  This caused problems like the ones
    reported in PR95726.

    The fix for that PR was to add type attributes to the <arm_neon.h>
    types, in order to maintain the distinction between them and GNU
    vectors.  However, this in turn caused PR98852, where cp_common_type
    would merge the type attributes from the two source types and attach
    the result to the common type.  For example:

       unsigned vector with no attribute + signed vector with attribute X

    would get converted to:

       unsigned vector with attribute X

    That isn't what we want in this case, since X describes the mangling
    of the original type.  But even if we dropped the mangling from X and
    worked it out from context, we would still have a situation in which
    the common type was provably distinct from both of the source types:
    it would take its <arm_neon.h>-ness from one side and its signedness
    from the other.  I guess there are other cases where the common type
    doesn't match either side, but I'm not sure it's the obvious behaviour
    here.  It's also different from GCC 10.1 and earlier, where the unsigned
    vector âwonâ in its original form.

    This patch instead merges only the attributes that don't affect type
    identity.  For now I've restricted it to vector types, since we're so
    close to GCC 11, but it might make sense to use this elsewhere.

    I've tried to audit the C and target-specific attributes to look for
    other types that might be affected by this, but I couldn't see any.
    The closest was s390_vector_bool, but the handler for that attribute
    changes the type node and drops the attribute itself
    (*no_add_attrs = true).

    gcc/
            PR c++/98852
            * attribs.h (restrict_type_identity_attributes_to): Declare.
            * attribs.c (restrict_type_identity_attributes_to): New function.

    gcc/cp/
            PR c++/98852
            * typeck.c (merge_type_attributes_from): New function.
            (cp_common_type): Use it for vector types.

Reply via email to