Add a testcase for PR 44806.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr44806.c
blobd0002d308d02e3bdb54534ef8754f3b4fb55cac9
1 /* { dg-do run } */
3 #include <stdint.h>
5 extern void abort (void);
7 #define N_DEV_BITS_4 5
8 #define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1)
10 #define N_DEV_BITS_8 8
11 #define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1)
13 struct dev_ino_4
15 uint32_t mode:2;
16 uint32_t short_ino:N_INO_BITS_4;
17 uint32_t mapped_dev:N_DEV_BITS_4;
18 uint32_t always_set:1;
21 struct dev_ino_8
23 uint32_t mode:2;
24 uint64_t short_ino:N_INO_BITS_8;
25 uint32_t mapped_dev:N_DEV_BITS_8;
26 uint32_t always_set:1;
29 struct dev_ino_full
31 uint32_t mode:2;
32 uint32_t dev;
33 uint32_t ino;
36 enum di_mode
38 DI_MODE_4 = 1,
39 DI_MODE_8 = 2,
40 DI_MODE_FULL = 3
43 struct di_ent
45 union
47 struct dev_ino_4 di4;
48 struct dev_ino_8 di8;
49 struct dev_ino_full full;
50 uint32_t u32;
51 uint64_t u64;
52 void *ptr;
53 } u;
56 static struct di_ent
57 decode_ptr (struct di_ent const *v)
59 struct di_ent di;
60 di.u.ptr = (void *) v;
61 return di;
64 static int
65 di_ent_equal (void const *x, void const *y)
67 struct di_ent a = decode_ptr (x);
68 struct di_ent b = decode_ptr (y);
69 if (a.u.di4.mode != b.u.di4.mode)
70 return 0;
72 if (a.u.di4.mode == DI_MODE_4)
73 return (a.u.di4.short_ino == b.u.di4.short_ino
74 && a.u.di4.mapped_dev == b.u.di4.mapped_dev);
76 if (a.u.di8.mode == DI_MODE_8)
77 return (a.u.di8.short_ino == b.u.di8.short_ino
78 && a.u.di8.mapped_dev == b.u.di8.mapped_dev);
80 return (a.u.full.ino == b.u.full.ino
81 && a.u.full.dev == b.u.full.dev);
84 int
85 main ()
87 if (di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851) != 0)
88 abort ();
89 return 0;