From: Dimitar Dimitrov Date: Mon, 5 Aug 2024 16:00:28 +0000 (+0300) Subject: testsuite: Fix struct size check [PR116155] X-Git-Tag: basepoints/gcc-16~6649 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b13e34699c7d27e561fcfe1b66ced1e50e69976f;p=thirdparty%2Fgcc.git testsuite: Fix struct size check [PR116155] The size of "struct only_fam_2" is dependent on the alignment of the flexible array member "b", and not on the type of the preceding bit-fields. For most targets the two are equal. But on default_packed targets like pru-unknown-elf, the alignment of int is not equal to the size of int, so the test failed. Patch was suggested by Qing Zhao. Tested on pru-unknown-elf and x86_64-pc-linux-gnu. PR testsuite/116155 gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: Adjust check to account for default_packed targets. Signed-off-by: Dimitar Dimitrov --- diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c index 39ebf17850b..9979e96fe70 100644 --- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c @@ -45,7 +45,7 @@ int main () __builtin_abort (); if (sizeof (struct only_fam) != 0) __builtin_abort (); - if (sizeof (struct only_fam_2) != sizeof (int)) + if (sizeof (struct only_fam_2) != __alignof__ (int)) __builtin_abort (); return 0; }