diff options
author | Martin Uecker <uecker@tugraz.at> | 2024-05-24 12:35:27 +0200 |
---|---|---|
committer | Martin Uecker <uecker@tugraz.at> | 2024-05-31 07:12:34 +0200 |
commit | d2cfe8a73b3c4195a25cde28e1641ef36ebb08c1 (patch) | |
tree | 3e850bee6f33861608d45b761a4d973420407b54 /gcc/cp | |
parent | 867d1264fe71d4291194373d1a1c409cac97a597 (diff) | |
download | gcc-d2cfe8a73b3c4195a25cde28e1641ef36ebb08c1.zip gcc-d2cfe8a73b3c4195a25cde28e1641ef36ebb08c1.tar.gz gcc-d2cfe8a73b3c4195a25cde28e1641ef36ebb08c1.tar.bz2 |
C23: allow aliasing for types derived from structs with variable size
Previously, we set the aliasing set of structures with variable size
struct foo { int x[n]; char b; };
to zero. The reason is that such types can be compatible to diffrent
structure types which are incompatible.
struct foo { int x[2]; char b; };
struct foo { int x[3]; char b; };
But it is not enough to set the aliasing set to zero, because derived
types would then still end up in different equivalence classes even
though they might be compatible. Instead those types should be set
to structural equivalency. We also add checking assertions that
ensure that TYPE_CANONICAL is set correctly for all tagged types.
gcc/c/
* c-decl.cc (finish_struct): Do not set TYPE_CANONICAL for
structure or unions with variable size.
* c-objc-common.cc (c_get_alias_set): Do not set alias set to zero.
* c-typeck.cc (comptypes_verify): New function.
(comptypes,comptypes_same_p,comptypes_check_enum_int): Add assertion.
(comptypes_equiv_p): Add assertion that ensures that compatible
types have the same equivalence class.
(tagged_types_tu_compatible_p): Remove now unneeded special case.
gcc/testsuite/
* gcc.dg/gnu23-tag-alias-8.c: New test.
Diffstat (limited to 'gcc/cp')
0 files changed, 0 insertions, 0 deletions