d: Merge upstream dmd, druntime 26f049fb26, phobos 330d6a4fd.
[official-gcc.git] / gcc / testsuite / gdc.test / compilable / dtoh_enum_cpp98.d
blob6a266d9be77e0a38b9dc83edd1de087891223daa
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
8 #pragma once
10 #include <assert.h>
11 #include <math.h>
12 #include <stddef.h>
13 #include <stdint.h>
15 #ifdef CUSTOM_D_ARRAY_TYPE
16 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
17 #else
18 /// Represents a D [] array
19 template<typename T>
20 struct _d_dynamicArray final
22 size_t length;
23 T *ptr;
25 _d_dynamicArray() : length(0), ptr(NULL) { }
27 _d_dynamicArray(size_t length_in, T *ptr_in)
28 : length(length_in), ptr(ptr_in) { }
30 T& operator[](const size_t idx) {
31 assert(idx < length);
32 return ptr[idx];
35 const T& operator[](const size_t idx) const {
36 assert(idx < length);
37 return ptr[idx];
40 #endif
42 static int32_t const Anon = 10;
44 static bool const Anon2 = true;
46 static const char* const Anon3 = "wow";
48 enum Enum
50 Enum_One = 0,
51 Enum_Two = 1,
54 enum EnumDefaultType
56 EnumDefaultType_One = 1,
57 EnumDefaultType_Two = 2,
60 enum EnumWithType
62 EnumWithType_One = 1,
63 EnumWithType_Two = 2,
66 enum
68 AnonOne = 1,
69 AnonTwo = 2,
72 enum
74 AnonWithTypeOne = 1LL,
75 AnonWithTypeTwo = 2LL,
78 namespace EnumWithStringType
80 static const char* const One = "1";
81 static const char* const Two = "2";
84 namespace EnumWithImplicitType
86 static const char* const One = "1";
87 static const char* const Two = "2";
90 namespace
92 static const char* const AnonWithStringOne = "1";
93 static const char* const AnonWithStringTwo = "2";
96 static int32_t const AnonMixedOne = 1;
97 static int64_t const AnonMixedTwo = 2LL;
98 static const char* const AnonMixedA = "a";
101 enum STC
103 STC_a = 1,
104 STC_b = 2,
107 static STC const STC_D = (STC)3;
109 struct Foo final
111 int32_t i;
112 Foo() :
116 Foo(int32_t i) :
117 i(i)
121 namespace MyEnum
123 static Foo const A = Foo(42);
124 static Foo const B = Foo(84);
127 static /* MyEnum */ Foo const test = Foo(42);
129 struct FooCpp final
131 int32_t i;
132 FooCpp() :
136 FooCpp(int32_t i) :
137 i(i)
141 namespace MyEnumCpp
143 static FooCpp const A = FooCpp(42);
144 static FooCpp const B = FooCpp(84);
147 static /* MyEnum */ Foo const testCpp = Foo(42);
149 extern const bool e_b;
153 extern(C++):
154 enum Anon = 10;
155 extern(C++) enum Anon2 = true;
156 extern(C++) enum Anon3 = "wow";
158 enum Enum
160 One,
164 enum EnumDefaultType : int
166 One = 1,
167 Two = 2
170 enum EnumWithType : byte
172 One = 1,
173 Two = 2
176 enum
178 AnonOne = 1,
179 AnonTwo = 2
182 enum : long
184 AnonWithTypeOne = 1,
185 AnonWithTypeTwo = 2
188 enum EnumWithStringType : string
190 One = "1",
191 Two = "2"
194 enum EnumWithImplicitType
196 One = "1",
197 Two = "2"
200 enum : string
202 AnonWithStringOne = "1",
203 AnonWithStringTwo = "2"
206 enum
208 AnonMixedOne = 1,
209 long AnonMixedTwo = 2,
210 string AnonMixedA = "a"
213 enum STC
215 a = 1,
216 b = 2,
219 extern(C++) enum STC_D = STC.a | STC.b;
221 struct Foo { int i; }
222 enum MyEnum { A = Foo(42), B = Foo(84) }
223 extern(C++) enum test = MyEnum.A;
225 extern(C++) struct FooCpp { int i; }
226 enum MyEnumCpp { A = FooCpp(42), B = FooCpp(84) }
227 extern(C++) enum testCpp = MyEnum.A;
229 // currently unsupported enums
230 extern(C++) enum b = [1, 2, 3];
231 extern(C++) enum c = [2: 3];
233 extern(C) void foo();
234 extern(C++) enum d = &foo;
236 __gshared immutable bool e_b;
237 extern(C++) enum e = &e_b;
239 // Opaque enums require C++ 11
240 enum opaque;
241 enum typedOpaque : long;
242 enum arrayOpaque : int[4];
244 extern(D) enum hidden_d = 42; // Linkage prevents being exported to C++