diff options
author | Martin Uecker <uecker@tugraz.at> | 2024-06-29 15:53:43 +0200 |
---|---|---|
committer | Martin Uecker <uecker@gcc.gnu.org> | 2024-07-09 21:05:46 +0200 |
commit | 7825c07bbaf503c47ecedd87e3d64be003b24f2c (patch) | |
tree | 94851853a2369e15753687013db8b77eba58103d /gcc/c | |
parent | 592a746533a278a5fd3e7b5dff004e1846ef26a4 (diff) | |
download | gcc-7825c07bbaf503c47ecedd87e3d64be003b24f2c.zip gcc-7825c07bbaf503c47ecedd87e3d64be003b24f2c.tar.gz gcc-7825c07bbaf503c47ecedd87e3d64be003b24f2c.tar.bz2 |
c: Fix ICE for redeclaration of structs with different alignment [PR114727]
For redeclarations of struct in C23, if one has an alignment attribute
that makes the alignment different, we later get an ICE in verify_types.
This patches disallows such redeclarations by declaring such types to
be different.
PR c/114727
gcc/c/
* c-typeck.cc (tagged_types_tu_compatible): Add test.
gcc/testsuite/
* gcc.dg/pr114727.c: New test.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-typeck.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index e486ac0..455dc37 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -1603,6 +1603,9 @@ tagged_types_tu_compatible_p (const_tree t1, const_tree t2, != TYPE_REVERSE_STORAGE_ORDER (t2))) return false; + if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2)) + data->different_types_p = true; + /* For types already being looked at in some active invocation of this function, assume compatibility. The cache is built as a linked list on the stack |