1 #include <cstdarg> 2 #include <cstdint> 3 #include <cstdlib> 4 #include <new> 5 6 enum class C : uint32_t { 7 X = 2, 8 Y, 9 }; 10 11 struct A { 12 int32_t m0; 13 AA14 A(int32_t const& aM0) 15 : m0(aM0) 16 {} 17 operator <A18 bool operator<(const A& other) const { 19 return m0 < other.m0; 20 } operator <=A21 bool operator<=(const A& other) const { 22 return m0 <= other.m0; 23 } 24 }; 25 26 struct B { 27 int32_t x; 28 float y; 29 }; 30 31 union F { 32 enum class Tag : uint8_t { 33 Foo, 34 Bar, 35 Baz, 36 }; 37 38 struct Foo_Body { 39 Tag tag; 40 int16_t _0; 41 }; 42 43 struct Bar_Body { 44 Tag tag; 45 uint8_t x; 46 int16_t y; 47 }; 48 49 struct { 50 Tag tag; 51 }; 52 Foo_Body foo; 53 Bar_Body bar; 54 Foo(const int16_t & a0)55 static F Foo(const int16_t &a0) { 56 F result; 57 ::new (&result.foo._0) (int16_t)(a0); 58 result.tag = Tag::Foo; 59 return result; 60 } 61 IsFoo() const62 bool IsFoo() const { 63 return tag == Tag::Foo; 64 } 65 Bar(const uint8_t & aX,const int16_t & aY)66 static F Bar(const uint8_t &aX, 67 const int16_t &aY) { 68 F result; 69 ::new (&result.bar.x) (uint8_t)(aX); 70 ::new (&result.bar.y) (int16_t)(aY); 71 result.tag = Tag::Bar; 72 return result; 73 } 74 IsBar() const75 bool IsBar() const { 76 return tag == Tag::Bar; 77 } 78 Baz()79 static F Baz() { 80 F result; 81 result.tag = Tag::Baz; 82 return result; 83 } 84 IsBaz() const85 bool IsBaz() const { 86 return tag == Tag::Baz; 87 } 88 }; 89 90 struct H { 91 enum class Tag : uint8_t { 92 Hello, 93 There, 94 Everyone, 95 }; 96 97 struct Hello_Body { 98 int16_t _0; 99 }; 100 101 struct There_Body { 102 uint8_t x; 103 int16_t y; 104 }; 105 106 Tag tag; 107 union { 108 Hello_Body hello; 109 There_Body there; 110 }; 111 HelloH112 static H Hello(const int16_t &a0) { 113 H result; 114 ::new (&result.hello._0) (int16_t)(a0); 115 result.tag = Tag::Hello; 116 return result; 117 } 118 IsHelloH119 bool IsHello() const { 120 return tag == Tag::Hello; 121 } 122 ThereH123 static H There(const uint8_t &aX, 124 const int16_t &aY) { 125 H result; 126 ::new (&result.there.x) (uint8_t)(aX); 127 ::new (&result.there.y) (int16_t)(aY); 128 result.tag = Tag::There; 129 return result; 130 } 131 IsThereH132 bool IsThere() const { 133 return tag == Tag::There; 134 } 135 EveryoneH136 static H Everyone() { 137 H result; 138 result.tag = Tag::Everyone; 139 return result; 140 } 141 IsEveryoneH142 bool IsEveryone() const { 143 return tag == Tag::Everyone; 144 } 145 }; 146 147 extern "C" { 148 149 void root(A x, B y, C z, F f, H h); 150 151 } // extern "C" 152