Debian Codegraph @

gcc/testsuite/gdc.test/compilable/extra-files/header2.d

raw
1 // for D 2.0 only
2
3 class C { }
4
5 void foo(const C c, const(char)[] s, const int* q, const (int*) p)
6 {
7 }
8
9 void bar(in void *p)
10 {
11 }
12
13 void f(void function() f2);
14
15 class C2;
16 void foo2(const C2 c);
17
18 struct Foo3
19 {
20 int k;
21 ~this() @trusted @disable @nogc @live { k = 1; }
22 this(this) { k = 2; }
23 }
24
25
26 class C3 { @property int get() { return 0; } }
27
28 T foo3(T)() {}
29
30 struct S4A(T)
31 {
32 T x;
33 ~this() @safe {}
34 }
35
36 struct S4B(T) if (1)
37 {
38 T x;
39 }
40
41 union U4A(T)
42 {
43 T x;
44 }
45
46 union U4B(T) if (2*4 == 8)
47 {
48 T x;
49 }
50
51 class C4A(T)
52 {
53 T x;
54 }
55
56 class C4B(T) if (true) { T x; }
57
58 class C4C(T) : C4A!int if (!false)
59 {
60 T x;
61 }
62
63 class C4D(T) if (!false) : C4B!long, C4C!(int[])
64 {
65 T x;
66 }
67
68 interface I4(T) if ((int[1]).length == 1) { T x; }
69
70 // eponymous template case
71 template MyClass4(T)
72 if (is(typeof(T.subtype)))
73 {
74 alias HelperSymbol = T.subtype;
75 class MyClass4 {}
76 }
77
78 enum isInt(T) = is(T == int);
79 enum bool isString(T) = is(T == string);
80 static immutable typeName(T) = T.stringof;
81 int storageFor(T) = 0;
82
83 template templateVariableFoo(T)
84 {
85 enum int templateVariableFoo = T.stringof.length;
86 }
87 template templateVariableBar(T) if (is(T == int))
88 {
89 enum int templateVariableBar = T.stringof.length;
90 }
91
92 auto flit = 3 / 2.0;
93
94 // https://issues.dlang.org/show_bug.cgi?id=11217
95 void foo11217()( const int[] arr) {}
96 void foo11217()(immutable int[] arr) {}
97 void foo11217()( ref int[] arr) {}
98 void foo11217()( lazy int[] arr) {}
99 void foo11217()( auto ref int[] arr) {}
100 void foo11217()( scope int[] arr) {}
101 void foo11217()( in int[] arr) {}
102 void foo11217()( inout int[] arr) {}
103
104 // https://issues.dlang.org/show_bug.cgi?id=13275
105 void test13275()
106 {
107 if ( auto n = 1) {}
108 if ( const n = 1) {}
109 if ( immutable n = 1) {}
110 if (shared n = 1) {}
111 if (shared const n = 1) {}
112
113 if ( int n = 1) {}
114
115 if ( const int n = 1) {}
116 if ( immutable int n = 1) {}
117 if (shared int n = 1) {}
118 if (shared const int n = 1) {}
119
120 if ( const(int) n = 1) {}
121 if ( immutable(int) n = 1) {}
122 if (shared (int) n = 1) {}
123 if (shared const(int) n = 1) {}
124
125 foreach ( e; [1,2]) {}
126 foreach ( const e; [1,2]) {}
127 foreach ( immutable e; [1,2]) {}
128 foreach (shared e; [1,2]) {}
129 foreach (shared const e; [1,2]) {}
130
131 foreach ( int e; [1,2]) {}
132 foreach ( const int e; [1,2]) {}
133 foreach ( immutable int e; [1,2]) {}
134 foreach (shared int e; [1,2]) {}
135 foreach (shared const int e; [1,2]) {}
136
137 foreach ( int e; [1,2]) {}
138 foreach ( const(int) e; [1,2]) {}
139 foreach ( immutable(int) e; [1,2]) {}
140 foreach (shared (int) e; [1,2]) {}
141 foreach (shared const(int) e; [1,2]) {}
142 }
143
144 // https://issues.dlang.org/show_bug.cgi?id=9766
145 align (1) struct S9766
146 {
147 align {}
148 align (true ? 2 : 3):
149 int var1;
150
151 align:
152 int var2;
153 }
154
155 align(2) struct S12200_1
156 {
157 align:
158 }
159
160 align(2) struct S12200_2
161 {
162 align(1):
163 }
164
165 // https://issues.dlang.org/show_bug.cgi?id=14694
166 inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow
167 {
168 alias U = inout(T);
169 static U* max(U* a, U* b) nothrow { return a > b ? a : b; }
170 static U* min(U* a, U* b) nothrow { return a < b ? a : b; }
171
172 auto b = max(r1.ptr, r2.ptr);
173 auto e = min(r1.ptr + r1.length, r2.ptr + r2.length);
174 return b < e ? b[0 .. e - b] : null;
175 }
176
177 // https://issues.dlang.org/show_bug.cgi?id=16140
178 void gun()()
179 {
180 int[] res;
181 while (auto va = fun()) {} // expression expected, not 'auto'
182
183 while (true)
184 if (auto va = fun()) {}
185 else break;
186 }
187
188 // https://issues.dlang.org/show_bug.cgi?id=14690
189 pragma(inline, true)
190 int fun(int a, int b)
191 {
192 return 3;
193 }
194
195 // https://issues.dlang.org/show_bug.cgi?id=16649
196 void leFoo()()
197 {
198 sign = a == 2 ? false : (y < 0) ^ sign;
199 sign = a == 2 ? false : sign ^ (y < 0);
200 sign = 2 + 3 | 7 + 5;
201 }
202
203 // https://issues.dlang.org/show_bug.cgi?id=17371
204 interface LeInterface
205 {}
206 class LeClass
207 {
208 this()
209 {
210 auto foo = new class () LeInterface {};
211 }
212 }
213 const levar = new class LeClass, LeInterface {};
214
215 // https://issues.dlang.org/show_bug.cgi?id=20074
216 class CC
217 {
218 void fun()() @safe
219 {
220 () @trusted pure
221 {
222 } ();
223 }
224 }
225
226 // https://issues.dlang.org/show_bug.cgi?id=17663
227 private:
228 public struct Export {}