On Sun, 26 May 2024, Martin Uecker wrote:

> This is the patch I sent previously, but I tried to improve the
> description and added a long comment.  This patch is needed so
> that we do not have to update TYPE_CANONICAL of structures / unions
> when a tagged type is completed that is (recursively) pointed to 
> by a member of the structure / union.
> 
> Bootstrapped and regression tested on x86_64.
> 
> 
>     C23: fix aliasing for structures/unions with incomplete types
>     
>     When incomplete structure/union types are completed later, compatibility
>     of struct types that contain pointers to such types changes.  When forming
>     equivalence classes for TYPE_CANONICAL, we therefor need to be 
> conservative
>     and treat all structs with the same tag which are pointer targets as
>     equivalent for purposed of determining equivalency of structure/union
>     types which contain such types as member. This avoids having to update
>     TYPE_CANONICAL of such structure/unions recursively. The pointer types
>     themselves are updated in c_update_type_canonical.
>     
>     gcc/c/
>             * c-typeck.cc (comptypes_internal): Add flag to track
>             whether a struct is the target of a pointer.
>             (tagged_types_tu_compatible): When forming equivalence
>             classes, treat nested pointed-to structs as equivalent.
>     
>     gcc/testsuite/
>             * gcc.dg/c23-tag-incomplete-alias-1.c: New test.

This patch is OK.

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to