Debian Codegraph @

gcc/testsuite/gcc.dg/field-merge-22.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 /* PR tree-optimization/118456 */
5 /* Check that compares with constants take into account sign/zero extension of
6 both the bitfield and of the shifting type. */
7
8 #define shift (__CHAR_BIT__ - 4)
9
10 struct S {
11 signed char a : shift + 2;
12 signed char b : shift + 2;
13 short ignore[0];
14 } s;
15
16 __attribute__((noipa)) int
17 foo (void)
18 {
19 return ((unsigned char) s.a) >> shift == 15
20 && ((unsigned char) s.b) >> shift == 0;
21 }
22
23 int
24 main ()
25 {
26 s.a = -1;
27 s.b = 1;
28 if (foo () != 1)
29 __builtin_abort ();
30 return 0;
31 }