]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Adjust fam-in-union-alone-in-struct-2.c to support BE [PR116148]
authorKewen Lin <linkw@linux.ibm.com>
Fri, 2 Aug 2024 00:29:22 +0000 (19:29 -0500)
committerKewen Lin <linkw@gcc.gnu.org>
Fri, 2 Aug 2024 00:29:22 +0000 (19:29 -0500)
As Andrew pointed out in PR116148, fam-in-union-alone-in-struct-2.c
was designed for little-endian, the recent commit r15-2403 made it
be tested with running on BE and PR116148 got exposed.

This patch is to adjust the expected data for members in with_fam_2_v
and with_fam_3_v by considering endianness, also update with_fam_3_v.b[1]
from 0x5f6f7f7f to 0x5f6f7f8f to avoid two "7f"s.

PR testsuite/116148

gcc/testsuite/ChangeLog:

* c-c++-common/fam-in-union-alone-in-struct-2.c: Define macros
WITH_FAM_2_V_B[03] and WITH_FAM_3_V_A[07] as endianness, update the
checking with these macros and initialize with_fam_3_v.b[1] with
0x5f6f7f8f instead of 0x5f6f7f7f.

gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c

index 93f9d5128f6e8ff96125e11a3681b7fbbaf51d2a..7845a7fbab3eea5996bc881a9c4c9b72012dbad2 100644 (file)
@@ -16,7 +16,7 @@ union with_fam_2 {
 union with_fam_3 {
   char a[];  
   int b[];  
-} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f7f}};
+} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f8f}};
 
 struct only_fam {
   int b[]; 
@@ -28,16 +28,28 @@ struct only_fam_2 {
   int b[]; 
 } only_fam_2_v = {{7, 11}};
 
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define WITH_FAM_2_V_B0 0x4f
+#define WITH_FAM_2_V_B3 0x1f
+#define WITH_FAM_3_V_A0 0x4f
+#define WITH_FAM_3_V_A7 0x5f
+#else
+#define WITH_FAM_2_V_B0 0x1f
+#define WITH_FAM_2_V_B3 0x4f
+#define WITH_FAM_3_V_A0 0x1f
+#define WITH_FAM_3_V_A7 0x8f
+#endif
+
 int main ()
 {
   if (with_fam_1_v.b[3] != 4
       || with_fam_1_v.b[0] != 1)
     __builtin_abort ();
-  if (with_fam_2_v.b[3] != 0x1f
-      || with_fam_2_v.b[0] != 0x4f)
+  if (with_fam_2_v.b[3] != WITH_FAM_2_V_B3
+      || with_fam_2_v.b[0] != WITH_FAM_2_V_B0)
     __builtin_abort ();
-  if (with_fam_3_v.a[0] != 0x4f
-      || with_fam_3_v.a[7] != 0x5f)
+  if (with_fam_3_v.a[0] != WITH_FAM_3_V_A0
+      || with_fam_3_v.a[7] != WITH_FAM_3_V_A7)
     __builtin_abort ();
   if (only_fam_v.b[0] != 7
       || only_fam_v.b[1] != 11)