Debian Codegraph @

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

raw
1 /+
2 REQUIRED_ARGS: -extern-std=c++98 -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 static int32_t const Anon = 10;
16
17 static bool const Anon2 = true;
18
19 static const char* const Anon3 = "wow";
20
21 enum Enum
22 {
23 Enum_One = 0,
24 Enum_Two = 1,
25 };
26
27 enum EnumDefaultType
28 {
29 EnumDefaultType_One = 1,
30 EnumDefaultType_Two = 2,
31 };
32
33 enum EnumWithType
34 {
35 EnumWithType_One = 1,
36 EnumWithType_Two = 2,
37 };
38
39 enum
40 {
41 AnonOne = 1,
42 AnonTwo = 2,
43 };
44
45 enum
46 {
47 AnonWithTypeOne = 1LL,
48 AnonWithTypeTwo = 2LL,
49 };
50
51 namespace EnumWithStringType
52 {
53 static const char* const One = "1";
54 static const char* const Two = "2";
55 };
56
57 namespace EnumWithImplicitType
58 {
59 static const char* const One = "1";
60 static const char* const Two = "2";
61 };
62
63 namespace
64 {
65 static const char* const AnonWithStringOne = "1";
66 static const char* const AnonWithStringTwo = "2";
67 };
68
69 static int32_t const AnonMixedOne = 1;
70 static int64_t const AnonMixedTwo = 2LL;
71 static const char* const AnonMixedA = "a";
72
73
74 enum STC
75 {
76 STC_a = 1,
77 STC_b = 2,
78 };
79
80 static STC const STC_D = (STC)3;
81
82 struct Foo final
83 {
84 int32_t i;
85 Foo() :
86 i()
87 {
88 }
89 Foo(int32_t i) :
90 i(i)
91 {}
92 };
93
94 namespace MyEnum
95 {
96 static Foo const A = Foo(42);
97 static Foo const B = Foo(84);
98 };
99
100 static /* MyEnum */ Foo const test = Foo(42);
101
102 struct FooCpp final
103 {
104 int32_t i;
105 FooCpp() :
106 i()
107 {
108 }
109 FooCpp(int32_t i) :
110 i(i)
111 {}
112 };
113
114 namespace MyEnumCpp
115 {
116 static FooCpp const A = FooCpp(42);
117 static FooCpp const B = FooCpp(84);
118 };
119
120 static /* MyEnum */ Foo const testCpp = Foo(42);
121
122 extern const bool e_b;
123 ---
124 +/
125
126 extern(C++):
127 enum Anon = 10;
128 extern(C++) enum Anon2 = true;
129 extern(C++) enum Anon3 = "wow";
130
131 enum Enum
132 {
133 One,
134 Two
135 }
136
137 enum EnumDefaultType : int
138 {
139 One = 1,
140 Two = 2
141 }
142
143 enum EnumWithType : byte
144 {
145 One = 1,
146 Two = 2
147 }
148
149 enum
150 {
151 AnonOne = 1,
152 AnonTwo = 2
153 }
154
155 enum : long
156 {
157 AnonWithTypeOne = 1,
158 AnonWithTypeTwo = 2
159 }
160
161 enum EnumWithStringType : string
162 {
163 One = "1",
164 Two = "2"
165 }
166
167 enum EnumWithImplicitType
168 {
169 One = "1",
170 Two = "2"
171 }
172
173 enum : string
174 {
175 AnonWithStringOne = "1",
176 AnonWithStringTwo = "2"
177 }
178
179 enum
180 {
181 AnonMixedOne = 1,
182 long AnonMixedTwo = 2,
183 string AnonMixedA = "a"
184 }
185
186 enum STC
187 {
188 a = 1,
189 b = 2,
190 }
191
192 extern(C++) enum STC_D = STC.a | STC.b;
193
194 struct Foo { int i; }
195 enum MyEnum { A = Foo(42), B = Foo(84) }
196 extern(C++) enum test = MyEnum.A;
197
198 extern(C++) struct FooCpp { int i; }
199 enum MyEnumCpp { A = FooCpp(42), B = FooCpp(84) }
200 extern(C++) enum testCpp = MyEnum.A;
201
202 // currently unsupported enums
203 extern(C++) enum b = [1, 2, 3];
204 extern(C++) enum c = [2: 3];
205
206 extern(C) void foo();
207 extern(C++) enum d = &foo;
208
209 __gshared immutable bool e_b;
210 extern(C++) enum e = &e_b;
211
212 // Opaque enums require C++ 11
213 enum opaque;
214 enum typedOpaque : long;
215 enum arrayOpaque : int[4];
216
217 extern(D) enum hidden_d = 42; // Linkage prevents being exported to C++