| 1 |
#include <stddef.h> |
| 2 |
#include <stdint.h> |
| 3 |
|
| 4 |
template<class X> |
| 5 |
struct Foo |
| 6 |
{ |
| 7 |
X *v; |
| 8 |
}; |
| 9 |
|
| 10 |
template<class X> |
| 11 |
struct Boo |
| 12 |
{ |
| 13 |
X *v; |
| 14 |
}; |
| 15 |
|
| 16 |
void test1(Foo<int> arg1) |
| 17 |
{ |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
void test2(int* arg2, Boo<int*> arg1) |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
template<int X, int Y> |
| 26 |
struct Test3 |
| 27 |
{ |
| 28 |
|
| 29 |
}; |
| 30 |
|
| 31 |
void test3(Test3<3,3> arg1) |
| 32 |
{ |
| 33 |
} |
| 34 |
|
| 35 |
void test4(Foo<int*> arg1, Boo<int*> arg2, Boo<int*> arg3, int*, Foo<double>) |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
void test5(Foo<int*> arg1, Boo<int*> arg2, Boo<int*> arg3) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
struct Goo |
| 44 |
{ |
| 45 |
|
| 46 |
template<class X> |
| 47 |
struct Foo |
| 48 |
{ |
| 49 |
X* v; |
| 50 |
}; |
| 51 |
|
| 52 |
template<class X> |
| 53 |
struct Boo |
| 54 |
{ |
| 55 |
template<class Y> |
| 56 |
struct Xoo |
| 57 |
{ |
| 58 |
Y* v; |
| 59 |
}; |
| 60 |
X* v; |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
void test6(Foo<Boo<Foo<void> > > arg1); |
| 65 |
void test7(Boo<void>::Xoo<int> arg1); |
| 66 |
}; |
| 67 |
|
| 68 |
void Goo::test6(Goo::Foo<Goo::Boo<Goo::Foo<void> > > arg1) |
| 69 |
{ |
| 70 |
} |
| 71 |
|
| 72 |
void Goo::test7(Goo::Boo<void>::Xoo<int> arg1) |
| 73 |
{ |
| 74 |
} |
| 75 |
|
| 76 |
struct P1 |
| 77 |
{ |
| 78 |
template<class T> |
| 79 |
struct Mem |
| 80 |
{ |
| 81 |
}; |
| 82 |
}; |
| 83 |
|
| 84 |
struct P2 |
| 85 |
{ |
| 86 |
template<class T> |
| 87 |
struct Mem |
| 88 |
{ |
| 89 |
}; |
| 90 |
}; |
| 91 |
|
| 92 |
void test8(P1::Mem<int>, P2::Mem<int>){} |
| 93 |
void test9(Foo<int**>, Foo<int*>, int**, int*){} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
class Test10 |
| 98 |
{ |
| 99 |
private: void test10(); |
| 100 |
public: void test11(); |
| 101 |
protected: void test12(); |
| 102 |
public: void test13() const; |
| 103 |
|
| 104 |
private: void test14(); // Private methods in D are always non-virtual |
| 105 |
public: virtual void test15(); |
| 106 |
protected: virtual void test16(); |
| 107 |
|
| 108 |
private: static void test17(); |
| 109 |
public: static void test18(); |
| 110 |
protected: static void test19(); |
| 111 |
}; |
| 112 |
|
| 113 |
Test10* Test10Ctor() |
| 114 |
{ |
| 115 |
return new Test10(); |
| 116 |
} |
| 117 |
|
| 118 |
void Test10Dtor(Test10*& ptr) |
| 119 |
{ |
| 120 |
delete ptr; |
| 121 |
ptr = 0; |
| 122 |
} |
| 123 |
|
| 124 |
void Test10::test10(){} |
| 125 |
void Test10::test11(){} |
| 126 |
void Test10::test12(){} |
| 127 |
void Test10::test13() const{} |
| 128 |
void Test10::test14(){} |
| 129 |
void Test10::test15(){} |
| 130 |
void Test10::test16(){} |
| 131 |
void Test10::test17(){} |
| 132 |
void Test10::test18(){} |
| 133 |
void Test10::test19(){} |
| 134 |
|
| 135 |
struct Test20 |
| 136 |
{ |
| 137 |
private: static int test20; |
| 138 |
protected: static int test21; |
| 139 |
public: static int test22; |
| 140 |
}; |
| 141 |
|
| 142 |
int Test20::test20 = 20; |
| 143 |
int Test20::test21 = 21; |
| 144 |
int Test20::test22 = 22; |
| 145 |
|
| 146 |
int test23(Test10**, Test10*, Test10***, Test10 const *const) |
| 147 |
{ |
| 148 |
return 1; |
| 149 |
} |
| 150 |
|
| 151 |
int test23b(Test10 const *const *const, Test10 const* const, Test10*) |
| 152 |
{ |
| 153 |
return 1; |
| 154 |
} |
| 155 |
|
| 156 |
void test24(int(*)(int,int)) |
| 157 |
{ |
| 158 |
} |
| 159 |
|
| 160 |
void test25(int arr[2][5][6][291]) |
| 161 |
{ |
| 162 |
} |
| 163 |
|
| 164 |
int test26(int arr[5][6][291]) |
| 165 |
{ |
| 166 |
return arr[1][1][1]; |
| 167 |
} |
| 168 |
|
| 169 |
void test27(int, ...){} |
| 170 |
void test28(int){} |
| 171 |
|
| 172 |
void test29(float){} |
| 173 |
void test30(const float){} |
| 174 |
|
| 175 |
template<class T> |
| 176 |
struct Array |
| 177 |
{ |
| 178 |
int dim; |
| 179 |
}; |
| 180 |
|
| 181 |
class Module |
| 182 |
{ |
| 183 |
public: |
| 184 |
static void imports(Module*); |
| 185 |
static int dim(Array<Module*>*); |
| 186 |
}; |
| 187 |
|
| 188 |
|
| 189 |
void Module::imports(Module*) |
| 190 |
{ |
| 191 |
} |
| 192 |
|
| 193 |
int Module::dim(Array<Module*>* arr) |
| 194 |
{ |
| 195 |
return arr->dim; |
| 196 |
} |
| 197 |
|
| 198 |
uint64_t testlongmangle(int a, unsigned int b, int64_t c, uint64_t d) |
| 199 |
{ |
| 200 |
return a + b + c + d; |
| 201 |
} |
| 202 |
|
| 203 |
unsigned long testCppLongMangle(long a, unsigned long b) |
| 204 |
{ |
| 205 |
return a + b; |
| 206 |
} |
| 207 |
|
| 208 |
unsigned long long testCppLongLongMangle(long long a, unsigned long long b) |
| 209 |
{ |
| 210 |
return a + b; |
| 211 |
} |
| 212 |
|
| 213 |
size_t testCppSizeTMangle(ptrdiff_t a, size_t b) |
| 214 |
{ |
| 215 |
return a + b; |
| 216 |
} |
| 217 |
|
| 218 |
int test31[2][2][2] = {1, 1, 1, 1, 1, 1, 1, 1}; |
| 219 |
int *test32 = 0; |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
class Expression; |
| 224 |
|
| 225 |
typedef int (*apply_fp_t)(Expression*, void*); |
| 226 |
|
| 227 |
class Expression |
| 228 |
{ |
| 229 |
int type; |
| 230 |
public: |
| 231 |
int apply(apply_fp_t fp, apply_fp_t fp2, void *param); |
| 232 |
int getType(); |
| 233 |
static Expression* create(int v); |
| 234 |
static void dispose(Expression*&); |
| 235 |
}; |
| 236 |
|
| 237 |
int Expression::apply(apply_fp_t fp, apply_fp_t fp2, void *param) |
| 238 |
{ |
| 239 |
return fp(this, param) * fp2(this, param); |
| 240 |
} |
| 241 |
|
| 242 |
int Expression::getType() |
| 243 |
{ |
| 244 |
return type; |
| 245 |
} |
| 246 |
|
| 247 |
Expression* Expression::create(int v) |
| 248 |
{ |
| 249 |
Expression *e = new Expression(); |
| 250 |
e->type = v; |
| 251 |
return e; |
| 252 |
} |
| 253 |
|
| 254 |
void Expression::dispose(Expression *&e) |
| 255 |
{ |
| 256 |
if (e) |
| 257 |
delete e; |
| 258 |
e = 0; |
| 259 |
} |
| 260 |
|
| 261 |
/*int test34(int v[0][0][0]) |
| 262 |
{ |
| 263 |
return 0; |
| 264 |
}*/ |
| 265 |
|
| 266 |
#ifndef _MSC_VER |
| 267 |
int test35(long double arg) |
| 268 |
{ |
| 269 |
return (int)arg; |
| 270 |
} |
| 271 |
#endif |
| 272 |
|
| 273 |
const char *test36(const char *arg) |
| 274 |
{ |
| 275 |
return arg; |
| 276 |
} |
| 277 |
|
| 278 |
class Test37 |
| 279 |
{ |
| 280 |
public: |
| 281 |
static Test37 *create(); |
| 282 |
bool test(); |
| 283 |
}; |
| 284 |
|
| 285 |
bool test37() |
| 286 |
{ |
| 287 |
Test37 *o = Test37::create(); |
| 288 |
return o->test(); |
| 289 |
} |
| 290 |
|
| 291 |
class Test38 |
| 292 |
{ |
| 293 |
public: |
| 294 |
int test(int, ...); |
| 295 |
static Test38* create(); |
| 296 |
static void dispose(Test38*&); |
| 297 |
}; |
| 298 |
|
| 299 |
int Test38::test(int a, ...) |
| 300 |
{ |
| 301 |
return a; |
| 302 |
} |
| 303 |
|
| 304 |
Test38* Test38::create() |
| 305 |
{ |
| 306 |
Test38 *t = new Test38(); |
| 307 |
return t; |
| 308 |
} |
| 309 |
|
| 310 |
void Test38::dispose(Test38 *&t) |
| 311 |
{ |
| 312 |
if (t) |
| 313 |
delete t; |
| 314 |
t = 0; |
| 315 |
} |
| 316 |
|
| 317 |
class S1 |
| 318 |
{ |
| 319 |
int val; |
| 320 |
public: |
| 321 |
static S1* init(int); |
| 322 |
S1(int v) : val(v) {} |
| 323 |
int value(); |
| 324 |
}; |
| 325 |
|
| 326 |
S1* S1::init(int x) |
| 327 |
{ |
| 328 |
return new S1(x); |
| 329 |
} |
| 330 |
|
| 331 |
int S1::value() |
| 332 |
{ |
| 333 |
return val; |
| 334 |
} |
| 335 |
|
| 336 |
template<class T> |
| 337 |
class S2 |
| 338 |
{ |
| 339 |
T val; |
| 340 |
public: |
| 341 |
static S2<T>* init(T); |
| 342 |
S2(T v) : val(v) {} |
| 343 |
T value(); |
| 344 |
}; |
| 345 |
|
| 346 |
template<> |
| 347 |
S2<int>* S2<int>::init(int x) |
| 348 |
{ |
| 349 |
return new S2<int>(x); |
| 350 |
} |
| 351 |
|
| 352 |
template<> |
| 353 |
int S2<int>::value() |
| 354 |
{ |
| 355 |
return val; |
| 356 |
} |
| 357 |
|
| 358 |
struct C1 |
| 359 |
{ |
| 360 |
const char *data; |
| 361 |
|
| 362 |
static C1* init(const char *p); |
| 363 |
|
| 364 |
C1(const char* p) : data(p) { } |
| 365 |
|
| 366 |
virtual const char* getDataCPP(); |
| 367 |
virtual const char* getDataD(); |
| 368 |
}; |
| 369 |
|
| 370 |
C1* C1::init(const char *p) |
| 371 |
{ |
| 372 |
return new C1(p); |
| 373 |
} |
| 374 |
|
| 375 |
const char* C1::getDataCPP() |
| 376 |
{ |
| 377 |
return data; |
| 378 |
} |
| 379 |
|
| 380 |
template<class T> |
| 381 |
struct C2 |
| 382 |
{ |
| 383 |
const T *data; |
| 384 |
|
| 385 |
static C2* init(const T *p); |
| 386 |
|
| 387 |
C2(const T* p) : data(p) { } |
| 388 |
|
| 389 |
virtual const T* getData(); |
| 390 |
}; |
| 391 |
|
| 392 |
template<> |
| 393 |
C2<char>* C2<char>::init(const char *p) |
| 394 |
{ |
| 395 |
return new C2<char>(p); |
| 396 |
} |
| 397 |
|
| 398 |
template<> |
| 399 |
const char* C2<char>::getData() |
| 400 |
{ |
| 401 |
return data; |
| 402 |
} |
| 403 |
|
| 404 |
int test39cpp(C2<char>* c2, S2<int>* s2) |
| 405 |
{ |
| 406 |
C2<char>* otherC2 = C2<char>::init(c2->getData()); |
| 407 |
if (c2->getData() != otherC2->getData()) |
| 408 |
return 1; |
| 409 |
S2<int>* otherS2 = S2<int>::init(s2->value()); |
| 410 |
if (s2->value() != otherS2->value()) |
| 411 |
return 2; |
| 412 |
return 0; |
| 413 |
} |
| 414 |
|
| 415 |
namespace foo |
| 416 |
{ |
| 417 |
namespace bar |
| 418 |
{ |
| 419 |
namespace baz |
| 420 |
{ |
| 421 |
int doStuff(int i) |
| 422 |
{ |
| 423 |
return i * 2; |
| 424 |
} |
| 425 |
} |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
template<typename ...T> void foovargs(T... args); |
| 430 |
|
| 431 |
void test40() |
| 432 |
{ |
| 433 |
foovargs<int, float>(1, 2.0f); |
| 434 |
char c = 'a'; |
| 435 |
foovargs<char*>(&c); |
| 436 |
} |
| 437 |
|
| 438 |
template<typename T, typename ...Args> |
| 439 |
void make_shared_poc(Args&... args); |
| 440 |
|
| 441 |
void test41() |
| 442 |
{ |
| 443 |
int a = 1; |
| 444 |
int b = 2; |
| 445 |
make_shared_poc<int, int, int>(a, b); |
| 446 |
|
| 447 |
} |