2015-05-04 Sandra Loosemore <sandra@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr44806.c
blob8b67b10f54c2f4c118c8c63158cc29dc29dd7144
1 /* { dg-do run } */
2 /* { dg-options "-std=c99" } */
4 #include <stdint.h>
6 extern void abort (void);
8 #define N_DEV_BITS_4 5
9 #define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1)
11 #define N_DEV_BITS_8 8
12 #define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1)
14 struct dev_ino_4
16 uint32_t mode:2;
17 uint32_t short_ino:N_INO_BITS_4;
18 uint32_t mapped_dev:N_DEV_BITS_4;
19 uint32_t always_set:1;
22 struct dev_ino_8
24 uint32_t mode:2;
25 uint64_t short_ino:N_INO_BITS_8;
26 uint32_t mapped_dev:N_DEV_BITS_8;
27 uint32_t always_set:1;
30 struct dev_ino_full
32 uint32_t mode:2;
33 uint32_t dev;
34 uint32_t ino;
37 enum di_mode
39 DI_MODE_4 = 1,
40 DI_MODE_8 = 2,
41 DI_MODE_FULL = 3
44 struct di_ent
46 union
48 struct dev_ino_4 di4;
49 struct dev_ino_8 di8;
50 struct dev_ino_full full;
51 uint32_t u32;
52 uint64_t u64;
53 void *ptr;
54 } u;
57 static struct di_ent
58 decode_ptr (struct di_ent const *v)
60 struct di_ent di;
61 di.u.ptr = (void *) v;
62 return di;
65 static int
66 di_ent_equal (void const *x, void const *y)
68 struct di_ent a = decode_ptr (x);
69 struct di_ent b = decode_ptr (y);
70 if (a.u.di4.mode != b.u.di4.mode)
71 return 0;
73 if (a.u.di4.mode == DI_MODE_4)
74 return (a.u.di4.short_ino == b.u.di4.short_ino
75 && a.u.di4.mapped_dev == b.u.di4.mapped_dev);
77 if (a.u.di8.mode == DI_MODE_8)
78 return (a.u.di8.short_ino == b.u.di8.short_ino
79 && a.u.di8.mapped_dev == b.u.di8.mapped_dev);
81 return (a.u.full.ino == b.u.full.ino
82 && a.u.full.dev == b.u.full.dev);
85 int
86 main ()
88 if (di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851) != 0)
89 abort ();
90 return 0;