2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-bool-3.c
blobf93547ac01614a9e668fbbb3ed56bab8c036a5b2
1 /* Test for _Bool bit-fields. They have the semantics of _Bool, at
2 least for now (DR#335 Spring 2007 discussion). */
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
4 /* { dg-do run } */
5 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
6 struct foo
8 _Bool a : 1;
9 } sf;
11 extern void abort (void);
12 extern void exit (int);
14 int
15 main (void)
17 int i;
18 for (i = 0; i < sizeof (struct foo); i++)
19 *((unsigned char *)&sf + i) = (unsigned char) -1;
20 sf.a = 2;
21 if (sf.a != 1)
22 abort ();
23 sf.a = 0;
24 if (sf.a != 0)
25 abort ();
26 sf.a = 0.2;
27 if (sf.a != 1)
28 abort ();
29 sf.a = &sf;
30 if (sf.a != 1)
31 abort ();
32 exit (0);