1 // { dg-do run }
2 // { dg-options "-ansi -pedantic-errors -fsigned-bitfields" }
3
4 // Copyright (C) 2001 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
6
7 typedef int Int;
8 typedef signed int SInt;
9 typedef unsigned int UInt;
10
11 struct A
12 {
13 SInt bitS : 1; // signed
14 UInt bitU : 1; // unsigned
15 Int bit : 1; // signedness by -f{signed,unsigned}-bitfields
16 };
17
main()18 int main ()
19 {
20 A a;
21
22 a.bitS = 1; // { dg-warning "overflow" }
23 a.bitU = 1;
24 a.bit = 1; // { dg-warning "overflow" }
25
26 if (a.bitS != -1)
27 return 1;
28 if (a.bitU != 1)
29 return 2;
30 if (a.bit != -1)
31 return 3;
32
33 return 0;
34 }
35