]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / dtoh_AliasDeclaration.d
1 /+
2 REQUIRED_ARGS: -HC=silent -c -o- -Icompilable/extra-files
3 PERMUTE_ARGS:
4 EXTRA_FILES: extra-files/dtoh_imports.d extra-files/dtoh_imports2.d
5
6 TEST_OUTPUT:
7 ---
8 // Automatically generated by Digital Mars D Compiler
9
10 #pragma once
11
12 #include <assert.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <math.h>
16
17 #ifdef CUSTOM_D_ARRAY_TYPE
18 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
19 #else
20 /// Represents a D [] array
21 template<typename T>
22 struct _d_dynamicArray final
23 {
24 size_t length;
25 T *ptr;
26
27 _d_dynamicArray() : length(0), ptr(NULL) { }
28
29 _d_dynamicArray(size_t length_in, T *ptr_in)
30 : length(length_in), ptr(ptr_in) { }
31
32 T& operator[](const size_t idx) {
33 assert(idx < length);
34 return ptr[idx];
35 }
36
37 const T& operator[](const size_t idx) const {
38 assert(idx < length);
39 return ptr[idx];
40 }
41 };
42 #endif
43
44 class C;
45
46 extern void importFunc();
47
48 class ImportsC
49 {
50 };
51
52 typedef int32_t MyStdcInt;
53
54 enum
55 {
56 IgnoreErrors = 0,
57 };
58
59 typedef int32_t T;
60
61 extern "C" int32_t x;
62
63 extern "C" int32_t foo(int32_t x);
64
65 extern int32_t foo2(int32_t x);
66
67 struct S;
68
69 typedef S aliasS;
70
71 struct S2;
72
73 typedef S2 aliasS2;
74
75 typedef C* aliasC;
76
77 class C2;
78
79 typedef C2* aliasC2;
80
81 typedef size_t(*F)(size_t x);
82
83 template <typename T, typename U>
84 struct TS final
85 {
86 TS()
87 {
88 }
89 };
90
91 template <typename T, typename U>
92 using TSD = TS<T, U>;
93 typedef TSD<int32_t, int16_t > TSI;
94
95 using aliasName = ImportsC;
96
97 using MyStdc = MyStdcInt;
98
99 struct FullImport final
100 {
101 using ImportsC = ::ImportsC;
102 using MyStdcInt = ::MyStdcInt;
103 FullImport()
104 {
105 }
106 };
107
108 struct SelectiveImports final
109 {
110 using aliasName = ::ImportsC;
111 SelectiveImports()
112 {
113 }
114 };
115
116 struct PrivateImport final
117 {
118 PrivateImport()
119 {
120 }
121 };
122
123 typedef /* noreturn */ char Impossible[0];
124
125 template <typename T>
126 struct Array final
127 {
128 // Ignoring var length alignment 0
129 uint32_t length;
130 Array()
131 {
132 }
133 };
134
135 typedef Array<char > DString;
136 ---
137 +/
138
139 extern (C++):
140
141 alias T = int;
142
143 extern (C) int x;
144
145 alias u = x;
146
147 extern (C) int foo(int x)
148 {
149 return x * 42;
150 }
151
152 alias fun = foo;
153
154 extern (C++) int foo2(int x)
155 {
156 return x * 42;
157 }
158
159 alias fun2 = foo2;
160
161 extern (C) struct S;
162
163 alias aliasS = S;
164
165 extern (C++) struct S2;
166
167 alias aliasS2 = S2;
168
169 extern (C) class C;
170
171 alias aliasC = C;
172
173 extern (C++) class C2;
174
175 alias aliasC2 = C2;
176
177 alias F = size_t function (size_t x);
178
179 extern(C++) struct TS(T, U) {}
180 alias TSD = TS;
181 alias TSI = TSD!(int, short);
182
183 public import dtoh_imports :
184 importFunc,
185 aliasName = ImportsC,
186 MyStdc = MyStdcInt;
187
188 struct FullImport
189 {
190 public import dtoh_imports;
191
192 }
193
194 struct SelectiveImports
195 {
196 public import dtoh_imports :
197 importFunc,
198 aliasName = ImportsC;
199
200 public static import dtoh_imports;
201 }
202
203 struct PrivateImport
204 {
205 import dtoh_imports;
206
207 }
208
209 alias Impossible = noreturn;
210
211 struct Array(T)
212 {
213 uint length;
214 alias opDollar = length;
215 alias dim = length;
216 }
217 alias DString = Array!(char);