aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKewen Lin <linkw@linux.ibm.com>2024-08-01 19:29:22 -0500
committerKewen Lin <linkw@gcc.gnu.org>2024-08-01 19:29:22 -0500
commit86e2dc89c5b8c9d9cca649a34a650e381a05b3a5 (patch)
tree5cf4d9a93f1dc8ed2a8c7a8322cdbd953252352a /gcc
parent02e83ff378ee71049b83f84792e7fd1e22f51790 (diff)
downloadgcc-86e2dc89c5b8c9d9cca649a34a650e381a05b3a5.zip
gcc-86e2dc89c5b8c9d9cca649a34a650e381a05b3a5.tar.gz
gcc-86e2dc89c5b8c9d9cca649a34a650e381a05b3a5.tar.bz2
testsuite: Adjust fam-in-union-alone-in-struct-2.c to support BE [PR116148]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c
index 93f9d51..7845a7f 100644
--- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c
+++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c
@@ -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)