]> git.ipfire.org Git - thirdparty/gcc.git/commit
C23: fix aliasing for structures/unions with incomplete types
authorMartin Uecker <uecker@tugraz.at>
Sat, 30 Mar 2024 18:49:48 +0000 (19:49 +0100)
committerMartin Uecker <uecker@tugraz.at>
Wed, 29 May 2024 20:23:00 +0000 (22:23 +0200)
commit86b98d939989427ff025bcfd536ad361fcdc699c
treea8f902b52285a418806953eefb73a34b32785650
parent915440eed21de367cb41857afb5273aff5bcb737
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.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c23-tag-incomplete-alias-1.c [new file with mode: 0644]