xref: /csrg-svn/old/dbx/tests/cc/bitfields.c (revision 44061)
1*44061Sbostic typedef unsigned int uint;
2*44061Sbostic 
3*44061Sbostic struct dot {
4*44061Sbostic     uint  cost		 :24;
5*44061Sbostic     uint  type	         : 3;
6*44061Sbostic     uint  dirToCenter	 : 3;
7*44061Sbostic     uint  pad		 : 1;
8*44061Sbostic     uint  pin		 : 1;
9*44061Sbostic     uint  traceback	 : 3;
10*44061Sbostic     uint  traceforward   : 3;
11*44061Sbostic     uint  expanded	 : 1;
12*44061Sbostic     uint  underDir	 : 3;
13*44061Sbostic     uint  underOffset	 : 4;
14*44061Sbostic     uint  start		 : 1;
15*44061Sbostic     uint  target	 : 1;
16*44061Sbostic     uint  owner		 : 6;
17*44061Sbostic     uint  segment	 : 7;
18*44061Sbostic     uint  intrinsicCost  : 3;
19*44061Sbostic };
20*44061Sbostic 
main()21*44061Sbostic main()
22*44061Sbostic {
23*44061Sbostic     struct dot junk;
24*44061Sbostic 
25*44061Sbostic     junk.owner = 63;
26*44061Sbostic     junk.segment = 1;
27*44061Sbostic     junk.intrinsicCost = 1;
28*44061Sbostic 
29*44061Sbostic     printf("owner = %d, segment = %d, intrinsicCost = %d\n",
30*44061Sbostic 	junk.owner, junk.segment, junk.intrinsicCost);
31*44061Sbostic     printf("done\n");
32*44061Sbostic     oldmain();
33*44061Sbostic }
34*44061Sbostic 
oldmain()35*44061Sbostic oldmain()
36*44061Sbostic {
37*44061Sbostic     struct {
38*44061Sbostic 	int first;
39*44061Sbostic 	int second;
40*44061Sbostic 	int a : 8;
41*44061Sbostic 	int b : 8;
42*44061Sbostic 	int c;
43*44061Sbostic     } x;
44*44061Sbostic 
45*44061Sbostic     x.first = 0;
46*44061Sbostic     x.second = 0;
47*44061Sbostic     x.a = 2;
48*44061Sbostic     x.b = 10;
49*44061Sbostic     x.c = 1;
50*44061Sbostic }
51