1 #include <stdint.h>
2 
3 int main(int argc, char const *argv[]) {
4   struct LargeBitsA {
5     unsigned int : 30, a : 20;
6   } lba;
7 
8   struct LargeBitsB {
9     unsigned int a : 1, : 11, : 12, b : 20;
10   } lbb;
11 
12   struct LargeBitsC {
13     unsigned int : 13, : 9, a : 1, b : 1, c : 5, d : 1, e : 20;
14   } lbc;
15 
16   struct LargeBitsD {
17     char arr[3];
18     unsigned int : 30, a : 20;
19   } lbd;
20 
21   // This case came up when debugging clang and models RecordDeclBits
22   struct BitExampleFromClangDeclContext {
23     class fields {
24       uint64_t : 13;
25       uint64_t : 9;
26 
27       uint64_t a: 1;
28       uint64_t b: 1;
29       uint64_t c: 1;
30       uint64_t d: 1;
31       uint64_t e: 1;
32       uint64_t f: 1;
33       uint64_t g: 1;
34       uint64_t h: 1;
35       uint64_t i: 1;
36       uint64_t j: 1;
37       uint64_t k: 1;
38 
39       // In order to reproduce the crash for this case we need the
40       // members of fields to stay private :-(
41       friend struct BitExampleFromClangDeclContext;
42     };
43 
44     union {
45       struct fields f;
46     };
47 
48     BitExampleFromClangDeclContext() {
49   f.a = 1;
50   f.b = 0;
51   f.c = 1;
52   f.d = 0;
53   f.e = 1;
54   f.f = 0;
55   f.g = 1;
56   f.h = 0;
57   f.i = 1;
58   f.j = 0;
59   f.k = 1;
60     }
61   } clang_example;
62 
63   class B {
64   public:
65     uint32_t b_a;
66   };
67 
68   class D : public B {
69   public:
70     uint32_t d_a : 1;
71   } derived;
72 
73   lba.a = 2;
74 
75   lbb.a = 1;
76   lbb.b = 3;
77 
78   lbc.a = 1;
79   lbc.b = 0;
80   lbc.c = 4;
81   lbc.d = 1;
82   lbc.e = 20;
83 
84   lbd.arr[0] = 'a';
85   lbd.arr[1] = 'b';
86   lbd.arr[2] = '\0';
87   lbd.a = 5;
88 
89   derived.b_a = 2;
90   derived.d_a = 1;
91 
92   return 0; // Set break point at this line.
93 }
94