Debian Codegraph @

gcc/testsuite/gdc.test/compilable/dtoh_enum.d

raw
1 /+
2 REQUIRED_ARGS: -HC -c -o-
3 PERMUTE_ARGS:
4 TEST_OUTPUT:
5 ---
6 // Automatically generated by Digital Mars D Compiler
7
8 #pragma once
9
10 #include <assert.h>
11 #include <math.h>
12 #include <stddef.h>
13 #include <stdint.h>
14
15 enum : int32_t { Anon = 10 };
16
17 enum : bool { Anon2 = true };
18
19 static const char* const Anon3 = "wow";
20
21 enum class Enum
22 {
23 One = 0,
24 Two = 1,
25 };
26
27 extern const Enum constEnum;
28
29 enum class EnumDefaultType
30 {
31 One = 1,
32 Two = 2,
33 };
34
35 enum class EnumWithType : int8_t
36 {
37 One = 1,
38 Two = 2,
39 };
40
41 enum
42 {
43 AnonOne = 1,
44 AnonTwo = 2,
45 };
46
47 enum : int64_t
48 {
49 AnonWithTypeOne = 1LL,
50 AnonWithTypeTwo = 2LL,
51 };
52
53 namespace EnumWithStringType
54 {
55 static const char* const One = "1";
56 static const char* const Two = "2";
57 };
58
59 namespace EnumWStringType
60 {
61 static const char16_t* const One = u"1";
62 };
63
64 namespace EnumDStringType
65 {
66 static const char32_t* const One = U"1";
67 };
68
69 namespace EnumWithImplicitType
70 {
71 static const char* const One = "1";
72 static const char* const Two = "2";
73 };
74
75 namespace
76 {
77 static const char* const AnonWithStringOne = "1";
78 static const char* const AnonWithStringTwo = "2";
79 };
80
81 enum : int32_t { AnonMixedOne = 1 };
82 enum : int64_t { AnonMixedTwo = 2LL };
83 static const char* const AnonMixedA = "a";
84
85
86 enum class STC
87 {
88 a = 1,
89 b = 2,
90 };
91
92 static STC const STC_D = (STC)3;
93
94 struct Foo final
95 {
96 int32_t i;
97 Foo() :
98 i()
99 {
100 }
101 Foo(int32_t i) :
102 i(i)
103 {}
104 };
105
106 namespace MyEnum
107 {
108 static Foo const A = Foo(42);
109 static Foo const B = Foo(84);
110 };
111
112 static /* MyEnum */ Foo const test = Foo(42);
113
114 struct FooCpp final
115 {
116 int32_t i;
117 FooCpp() :
118 i()
119 {
120 }
121 FooCpp(int32_t i) :
122 i(i)
123 {}
124 };
125
126 namespace MyEnumCpp
127 {
128 static FooCpp const A = FooCpp(42);
129 static FooCpp const B = FooCpp(84);
130 };
131
132 static /* MyEnum */ Foo const testCpp = Foo(42);
133
134 extern const bool e_b;
135
136 enum class opaque;
137 enum class typedOpaque : int64_t;
138 ---
139 +/
140
141 extern(C++):
142
143 enum Anon = 10;
144 extern(C++) enum Anon2 = true;
145 extern(C++) enum Anon3 = "wow";
146
147 enum Enum
148 {
149 One,
150 Two
151 }
152
153 extern(C++) __gshared const(Enum) constEnum;
154
155 enum EnumDefaultType : int
156 {
157 One = 1,
158 Two = 2
159 }
160
161 enum EnumWithType : byte
162 {
163 One = 1,
164 Two = 2
165 }
166
167 enum
168 {
169 AnonOne = 1,
170 AnonTwo = 2
171 }
172
173 enum : long
174 {
175 AnonWithTypeOne = 1,
176 AnonWithTypeTwo = 2
177 }
178
179 enum EnumWithStringType : string
180 {
181 One = "1",
182 Two = "2"
183 }
184
185 enum EnumWStringType : wstring
186 {
187 One = "1"
188 }
189
190 enum EnumDStringType : dstring
191 {
192 One = "1"
193 }
194
195 enum EnumWithImplicitType
196 {
197 One = "1",
198 Two = "2"
199 }
200
201 enum : string
202 {
203 AnonWithStringOne = "1",
204 AnonWithStringTwo = "2"
205 }
206
207 enum
208 {
209 AnonMixedOne = 1,
210 long AnonMixedTwo = 2,
211 string AnonMixedA = "a"
212 }
213
214 enum STC
215 {
216 a = 1,
217 b = 2,
218 }
219
220 extern(C++) enum STC_D = STC.a | STC.b;
221
222 struct Foo { int i; }
223 enum MyEnum { A = Foo(42), B = Foo(84) }
224 extern(C++) enum test = MyEnum.A;
225
226 extern(C++) struct FooCpp { int i; }
227 enum MyEnumCpp { A = FooCpp(42), B = FooCpp(84) }
228 extern(C++) enum testCpp = MyEnum.A;
229
230 // currently unsupported enums
231 extern(C++) enum b = [1, 2, 3];
232 extern(C++) enum c = [2: 3];
233
234 extern(C) void foo();
235 extern(C++) enum d = &foo;
236
237 __gshared immutable bool e_b;
238 extern(C++) enum e = &e_b;
239
240 enum opaque;
241 enum typedOpaque : long;
242 enum arrayOpaque : int[4]; // Cannot be exported to C++
243
244 extern(D) enum hidden_d = 42; // Linkage prevents being exported to C++