aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-objc-common.cc
diff options
context:
space:
mode:
authorMartin Uecker <uecker@tugraz.at>2024-05-24 12:35:27 +0200
committerMartin Uecker <uecker@tugraz.at>2024-05-31 07:12:34 +0200
commitd2cfe8a73b3c4195a25cde28e1641ef36ebb08c1 (patch)
tree3e850bee6f33861608d45b761a4d973420407b54 /gcc/c/c-objc-common.cc
parent867d1264fe71d4291194373d1a1c409cac97a597 (diff)
downloadgcc-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/c/c-objc-common.cc')
-rw-r--r--gcc/c/c-objc-common.cc5
1 files changed, 0 insertions, 5 deletions
diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc
index 283f6a8..738e899 100644
--- a/gcc/c/c-objc-common.cc
+++ b/gcc/c/c-objc-common.cc
@@ -420,11 +420,6 @@ c_var_mod_p (tree x, tree fn ATTRIBUTE_UNUSED)
alias_set_type
c_get_alias_set (tree t)
{
- /* Structs with variable size can alias different incompatible
- structs. Let them alias anything. */
- if (RECORD_OR_UNION_TYPE_P (t) && C_TYPE_VARIABLE_SIZE (t))
- return 0;
-
return c_common_get_alias_set (t);
}