| 1 |
// EXTRA_FILES: cppmangle2.d |
| 2 |
// Test C++ name mangling. |
| 3 |
// https://issues.dlang.org/show_bug.cgi?id=4059 |
| 4 |
// https://issues.dlang.org/show_bug.cgi?id=5148 |
| 5 |
// https://issues.dlang.org/show_bug.cgi?id=7024 |
| 6 |
// https://issues.dlang.org/show_bug.cgi?id=10058 |
| 7 |
|
| 8 |
import core.stdc.stdio; |
| 9 |
|
| 10 |
version (CppRuntime_LLVM) version = CppMangle_Itanium; |
| 11 |
version (CppRuntime_GNU) version = CppMangle_Itanium; |
| 12 |
version (CppRuntime_Microsoft) version = CppMangle_MSVC; |
| 13 |
version (CppRuntime_Sun) version = CppMangle_Itanium; |
| 14 |
|
| 15 |
extern (C++) int foob(int i, int j, int k); |
| 16 |
|
| 17 |
class C |
| 18 |
{ |
| 19 |
extern (C++) int bar(int i, int j, int k) |
| 20 |
{ |
| 21 |
printf("this = %p\n", this); |
| 22 |
printf("i = %d\n", i); |
| 23 |
printf("j = %d\n", j); |
| 24 |
printf("k = %d\n", k); |
| 25 |
return 1; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
extern (C++) |
| 31 |
int foo(int i, int j, int k) |
| 32 |
{ |
| 33 |
printf("i = %d\n", i); |
| 34 |
printf("j = %d\n", j); |
| 35 |
printf("k = %d\n", k); |
| 36 |
assert(i == 1); |
| 37 |
assert(j == 2); |
| 38 |
assert(k == 3); |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
void test1() |
| 43 |
{ |
| 44 |
foo(1, 2, 3); |
| 45 |
|
| 46 |
auto i = foob(1, 2, 3); |
| 47 |
assert(i == 7); |
| 48 |
|
| 49 |
C c = new C(); |
| 50 |
c.bar(4, 5, 6); |
| 51 |
} |
| 52 |
|
| 53 |
version (CppMangle_Itanium) |
| 54 |
{ |
| 55 |
static assert(foo.mangleof == "_Z3fooiii"); |
| 56 |
static assert(foob.mangleof == "_Z4foobiii"); |
| 57 |
static assert(C.bar.mangleof == "_ZN1C3barEiii"); |
| 58 |
} |
| 59 |
version (CppMangle_MSVC) |
| 60 |
{ |
| 61 |
version (Win32) |
| 62 |
{ |
| 63 |
static assert(foo.mangleof == "?foo@@YAHHHH@Z"); |
| 64 |
static assert(foob.mangleof == "?foob@@YAHHHH@Z"); |
| 65 |
static assert(C.bar.mangleof == "?bar@C@@UAEHHHH@Z"); |
| 66 |
} |
| 67 |
version (Win64) |
| 68 |
{ |
| 69 |
static assert(foo.mangleof == "?foo@@YAHHHH@Z"); |
| 70 |
static assert(foob.mangleof == "?foob@@YAHHHH@Z"); |
| 71 |
static assert(C.bar.mangleof == "?bar@C@@UEAAHHHH@Z"); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
/****************************************/ |
| 76 |
|
| 77 |
extern (C++) |
| 78 |
interface D |
| 79 |
{ |
| 80 |
int bar(int i, int j, int k); |
| 81 |
} |
| 82 |
|
| 83 |
extern (C++) D getD(); |
| 84 |
|
| 85 |
void test2() |
| 86 |
{ |
| 87 |
D d = getD(); |
| 88 |
int i = d.bar(9,10,11); |
| 89 |
assert(i == 8); |
| 90 |
} |
| 91 |
|
| 92 |
version (CppMangle_Itanium) |
| 93 |
{ |
| 94 |
static assert (getD.mangleof == "_Z4getDv"); |
| 95 |
static assert (D.bar.mangleof == "_ZN1D3barEiii"); |
| 96 |
} |
| 97 |
|
| 98 |
/****************************************/ |
| 99 |
|
| 100 |
extern (C++) int callE(E); |
| 101 |
|
| 102 |
extern (C++) |
| 103 |
interface E |
| 104 |
{ |
| 105 |
int bar(int i, int j, int k); |
| 106 |
} |
| 107 |
|
| 108 |
class F : E |
| 109 |
{ |
| 110 |
extern (C++) int bar(int i, int j, int k) |
| 111 |
{ |
| 112 |
printf("F.bar: i = %d\n", i); |
| 113 |
printf("F.bar: j = %d\n", j); |
| 114 |
printf("F.bar: k = %d\n", k); |
| 115 |
assert(i == 11); |
| 116 |
assert(j == 12); |
| 117 |
assert(k == 13); |
| 118 |
return 8; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
void test3() |
| 123 |
{ |
| 124 |
F f = new F(); |
| 125 |
int i = callE(f); |
| 126 |
assert(i == 8); |
| 127 |
} |
| 128 |
|
| 129 |
version (CppMangle_Itanium) |
| 130 |
{ |
| 131 |
static assert (callE.mangleof == "_Z5callEP1E"); |
| 132 |
static assert (E.bar.mangleof == "_ZN1E3barEiii"); |
| 133 |
static assert (F.bar.mangleof == "_ZN1F3barEiii"); |
| 134 |
} |
| 135 |
|
| 136 |
/****************************************/ |
| 137 |
|
| 138 |
extern (C++) void foo4(char* p); |
| 139 |
|
| 140 |
void test4() |
| 141 |
{ |
| 142 |
foo4(null); |
| 143 |
} |
| 144 |
|
| 145 |
version (CppMangle_Itanium) |
| 146 |
{ |
| 147 |
static assert(foo4.mangleof == "_Z4foo4Pc"); |
| 148 |
} |
| 149 |
|
| 150 |
/****************************************/ |
| 151 |
|
| 152 |
extern(C++) |
| 153 |
{ |
| 154 |
struct foo5 { int i; int j; void* p; } |
| 155 |
|
| 156 |
interface bar5{ |
| 157 |
foo5 getFoo(int i); |
| 158 |
} |
| 159 |
|
| 160 |
bar5 newBar(); |
| 161 |
} |
| 162 |
|
| 163 |
void test5() |
| 164 |
{ |
| 165 |
bar5 b = newBar(); |
| 166 |
foo5 f = b.getFoo(4); |
| 167 |
printf("f.p = %p, b = %p\n", f.p, cast(void*)b); |
| 168 |
assert(f.p == cast(void*)b); |
| 169 |
} |
| 170 |
|
| 171 |
version (CppMangle_Itanium) |
| 172 |
{ |
| 173 |
static assert(bar5.getFoo.mangleof == "_ZN4bar56getFooEi"); |
| 174 |
static assert (newBar.mangleof == "_Z6newBarv"); |
| 175 |
} |
| 176 |
|
| 177 |
/****************************************/ |
| 178 |
|
| 179 |
extern(C++) |
| 180 |
{ |
| 181 |
struct S6 |
| 182 |
{ |
| 183 |
int i; |
| 184 |
double d; |
| 185 |
} |
| 186 |
S6 foo6(); |
| 187 |
} |
| 188 |
|
| 189 |
extern (C) int foosize6(); |
| 190 |
|
| 191 |
void test6() |
| 192 |
{ |
| 193 |
S6 f = foo6(); |
| 194 |
printf("%d %d\n", foosize6(), cast(int)S6.sizeof); |
| 195 |
assert(foosize6() == S6.sizeof); |
| 196 |
assert(f.i == 42); |
| 197 |
printf("f.d = %g\n", f.d); |
| 198 |
assert(f.d == 2.5); |
| 199 |
} |
| 200 |
|
| 201 |
version (CppMangle_Itanium) |
| 202 |
{ |
| 203 |
static assert (foo6.mangleof == "_Z4foo6v"); |
| 204 |
} |
| 205 |
|
| 206 |
/****************************************/ |
| 207 |
|
| 208 |
extern (C) int foo7(); |
| 209 |
|
| 210 |
struct S |
| 211 |
{ |
| 212 |
int i; |
| 213 |
long l; |
| 214 |
} |
| 215 |
|
| 216 |
void test7() |
| 217 |
{ |
| 218 |
printf("%d %d\n", foo7(), cast(int)S.sizeof); |
| 219 |
assert(foo7() == S.sizeof); |
| 220 |
} |
| 221 |
|
| 222 |
/****************************************/ |
| 223 |
|
| 224 |
extern (C++) void foo8(const char *); |
| 225 |
|
| 226 |
void test8() |
| 227 |
{ |
| 228 |
char c; |
| 229 |
foo8(&c); |
| 230 |
} |
| 231 |
|
| 232 |
version (CppMangle_Itanium) |
| 233 |
{ |
| 234 |
static assert(foo8.mangleof == "_Z4foo8PKc"); |
| 235 |
} |
| 236 |
|
| 237 |
/****************************************/ |
| 238 |
// https://issues.dlang.org/show_bug.cgi?id=4059 |
| 239 |
|
| 240 |
struct elem9 { } |
| 241 |
|
| 242 |
extern(C++) void foobar9(elem9*, elem9*); |
| 243 |
|
| 244 |
void test9() |
| 245 |
{ |
| 246 |
elem9 *a; |
| 247 |
foobar9(a, a); |
| 248 |
} |
| 249 |
|
| 250 |
version (CppMangle_Itanium) |
| 251 |
{ |
| 252 |
static assert(foobar9.mangleof == "_Z7foobar9P5elem9S0_"); |
| 253 |
} |
| 254 |
|
| 255 |
/****************************************/ |
| 256 |
// https://issues.dlang.org/show_bug.cgi?id=5148 |
| 257 |
|
| 258 |
extern (C++) |
| 259 |
{ |
| 260 |
void foo10(const char*, const char*); |
| 261 |
void foo10(const int, const int); |
| 262 |
void foo10(const char, const char); |
| 263 |
|
| 264 |
struct MyStructType { } |
| 265 |
void foo10(const MyStructType s, const MyStructType t); |
| 266 |
|
| 267 |
enum MyEnumType { onemember } |
| 268 |
void foo10(const MyEnumType s, const MyEnumType t); |
| 269 |
} |
| 270 |
|
| 271 |
void test10() |
| 272 |
{ |
| 273 |
char* p; |
| 274 |
foo10(p, p); |
| 275 |
foo10(1,2); |
| 276 |
foo10('c','d'); |
| 277 |
MyStructType s; |
| 278 |
foo10(s,s); |
| 279 |
MyEnumType e; |
| 280 |
foo10(e,e); |
| 281 |
} |
| 282 |
|
| 283 |
// https://issues.dlang.org/show_bug.cgi?id=19504 |
| 284 |
extern(C++) struct Class19504 { |
| 285 |
pragma(mangle, "HOHOHO") |
| 286 |
~this(); |
| 287 |
} |
| 288 |
static assert(Class19504.__xdtor.mangleof == "HOHOHO"); |
| 289 |
|
| 290 |
/**************************************/ |
| 291 |
// https://issues.dlang.org/show_bug.cgi?id=10058 |
| 292 |
|
| 293 |
extern (C++) |
| 294 |
{ |
| 295 |
void test10058a(void*) { } |
| 296 |
void test10058b(void function(void*)) { } |
| 297 |
void test10058c(void* function(void*)) { } |
| 298 |
void test10058d(void function(void*), void*) { } |
| 299 |
void test10058e(void* function(void*), void*) { } |
| 300 |
void test10058f(void* function(void*), void* function(void*)) { } |
| 301 |
void test10058g(void function(void*), void*, void*) { } |
| 302 |
void test10058h(void* function(void*), void*, void*) { } |
| 303 |
void test10058i(void* function(void*), void* function(void*), void*) { } |
| 304 |
void test10058j(void* function(void*), void* function(void*), void* function(void*)) { } |
| 305 |
void test10058k(void* function(void*), void* function(const (void)*)) { } |
| 306 |
void test10058l(void* function(void*), void* function(const (void)*), const(void)* function(void*)) { } |
| 307 |
} |
| 308 |
|
| 309 |
version (CppMangle_Itanium) |
| 310 |
{ |
| 311 |
static assert(test10058a.mangleof == "_Z10test10058aPv"); |
| 312 |
static assert(test10058b.mangleof == "_Z10test10058bPFvPvE"); |
| 313 |
static assert(test10058c.mangleof == "_Z10test10058cPFPvS_E"); |
| 314 |
static assert(test10058d.mangleof == "_Z10test10058dPFvPvES_"); |
| 315 |
static assert(test10058e.mangleof == "_Z10test10058ePFPvS_ES_"); |
| 316 |
static assert(test10058f.mangleof == "_Z10test10058fPFPvS_ES1_"); |
| 317 |
static assert(test10058g.mangleof == "_Z10test10058gPFvPvES_S_"); |
| 318 |
static assert(test10058h.mangleof == "_Z10test10058hPFPvS_ES_S_"); |
| 319 |
static assert(test10058i.mangleof == "_Z10test10058iPFPvS_ES1_S_"); |
| 320 |
static assert(test10058j.mangleof == "_Z10test10058jPFPvS_ES1_S1_"); |
| 321 |
static assert(test10058k.mangleof == "_Z10test10058kPFPvS_EPFS_PKvE"); |
| 322 |
static assert(test10058l.mangleof == "_Z10test10058lPFPvS_EPFS_PKvEPFS3_S_E"); |
| 323 |
} |
| 324 |
|
| 325 |
/**************************************/ |
| 326 |
// https://issues.dlang.org/show_bug.cgi?id=11696 |
| 327 |
|
| 328 |
class Expression; |
| 329 |
struct Loc {} |
| 330 |
|
| 331 |
extern(C++) |
| 332 |
class CallExp |
| 333 |
{ |
| 334 |
static void test11696a(Loc, Expression, Expression); |
| 335 |
static void test11696b(Loc, Expression, Expression*); |
| 336 |
static void test11696c(Loc, Expression*, Expression); |
| 337 |
static void test11696d(Loc, Expression*, Expression*); |
| 338 |
} |
| 339 |
|
| 340 |
version (CppMangle_Itanium) |
| 341 |
{ |
| 342 |
static assert(CallExp.test11696a.mangleof == "_ZN7CallExp10test11696aE3LocP10ExpressionS2_"); |
| 343 |
static assert(CallExp.test11696b.mangleof == "_ZN7CallExp10test11696bE3LocP10ExpressionPS2_"); |
| 344 |
static assert(CallExp.test11696c.mangleof == "_ZN7CallExp10test11696cE3LocPP10ExpressionS2_"); |
| 345 |
static assert(CallExp.test11696d.mangleof == "_ZN7CallExp10test11696dE3LocPP10ExpressionS3_"); |
| 346 |
} |
| 347 |
|
| 348 |
/**************************************/ |
| 349 |
// https://issues.dlang.org/show_bug.cgi?id=13337 |
| 350 |
|
| 351 |
extern(C++, N13337a.N13337b.N13337c) |
| 352 |
{ |
| 353 |
struct S13337{} |
| 354 |
void foo13337(S13337 s); |
| 355 |
} |
| 356 |
|
| 357 |
extern(C++, `N13337a`, `N13337b`, `N13337c`) |
| 358 |
{ |
| 359 |
struct S13337_2{} |
| 360 |
void foo13337_2(S13337 s); |
| 361 |
void foo13337_3(S13337_2 s); |
| 362 |
} |
| 363 |
|
| 364 |
version (CppMangle_Itanium) |
| 365 |
{ |
| 366 |
static assert(foo13337.mangleof == "_ZN7N13337a7N13337b7N13337c8foo13337ENS1_6S13337E"); |
| 367 |
static assert(foo13337_2.mangleof == "_ZN7N13337a7N13337b7N13337c10foo13337_2ENS1_6S13337E"); |
| 368 |
static assert(foo13337_3.mangleof == "_ZN7N13337a7N13337b7N13337c10foo13337_3ENS1_8S13337_2E"); |
| 369 |
} |
| 370 |
|
| 371 |
/**************************************/ |
| 372 |
// https://issues.dlang.org/show_bug.cgi?id=15789 |
| 373 |
|
| 374 |
extern (C++) void test15789a(T...)(T args); |
| 375 |
|
| 376 |
void test15789() |
| 377 |
{ |
| 378 |
test15789a(0); |
| 379 |
} |
| 380 |
|
| 381 |
/**************************************/ |
| 382 |
// https://issues.dlang.org/show_bug.cgi?id=7030 |
| 383 |
|
| 384 |
extern(C++) |
| 385 |
{ |
| 386 |
struct Struct7030 |
| 387 |
{ |
| 388 |
void foo(int) const; |
| 389 |
void bar(int); |
| 390 |
static __gshared int boo; |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
version (CppMangle_Itanium) |
| 395 |
{ |
| 396 |
static assert(Struct7030.foo.mangleof == "_ZNK10Struct70303fooEi"); |
| 397 |
static assert(Struct7030.bar.mangleof == "_ZN10Struct70303barEi"); |
| 398 |
static assert(Struct7030.boo.mangleof == "_ZN10Struct70303booE"); |
| 399 |
} |
| 400 |
|
| 401 |
/****************************************/ |
| 402 |
|
| 403 |
// Special cases of Itanium mangling |
| 404 |
|
| 405 |
extern (C++, std) |
| 406 |
{ |
| 407 |
struct pair(T1, T2) |
| 408 |
{ |
| 409 |
void swap(ref pair other); |
| 410 |
} |
| 411 |
|
| 412 |
struct allocator(T) |
| 413 |
{ |
| 414 |
uint fooa() const; |
| 415 |
uint foob(); |
| 416 |
} |
| 417 |
|
| 418 |
struct basic_string(T1, T2, T3) |
| 419 |
{ |
| 420 |
uint fooa(); |
| 421 |
} |
| 422 |
|
| 423 |
struct basic_istream(T1, T2) |
| 424 |
{ |
| 425 |
uint fooc(); |
| 426 |
} |
| 427 |
|
| 428 |
struct basic_ostream(T1, T2) |
| 429 |
{ |
| 430 |
uint food(); |
| 431 |
} |
| 432 |
|
| 433 |
struct basic_iostream(T1, T2) |
| 434 |
{ |
| 435 |
uint fooe(); |
| 436 |
} |
| 437 |
|
| 438 |
struct char_traits(T) |
| 439 |
{ |
| 440 |
uint foof(); |
| 441 |
} |
| 442 |
|
| 443 |
struct vector (T); |
| 444 |
|
| 445 |
struct test18957 {} |
| 446 |
} |
| 447 |
|
| 448 |
extern (C++, `std`) |
| 449 |
{ |
| 450 |
struct pair(T1, T2) |
| 451 |
{ |
| 452 |
void swap(ref pair other); |
| 453 |
} |
| 454 |
|
| 455 |
struct allocator(T) |
| 456 |
{ |
| 457 |
uint fooa() const; |
| 458 |
uint foob(); |
| 459 |
} |
| 460 |
|
| 461 |
struct basic_string(T1, T2, T3) |
| 462 |
{ |
| 463 |
uint fooa(); |
| 464 |
} |
| 465 |
|
| 466 |
struct basic_istream(T1, T2) |
| 467 |
{ |
| 468 |
uint fooc(); |
| 469 |
} |
| 470 |
|
| 471 |
struct basic_ostream(T1, T2) |
| 472 |
{ |
| 473 |
uint food(); |
| 474 |
} |
| 475 |
|
| 476 |
struct basic_iostream(T1, T2) |
| 477 |
{ |
| 478 |
uint fooe(); |
| 479 |
} |
| 480 |
|
| 481 |
struct char_traits(T) |
| 482 |
{ |
| 483 |
uint foof(); |
| 484 |
} |
| 485 |
|
| 486 |
struct vector (T); |
| 487 |
|
| 488 |
struct Struct18957 {} |
| 489 |
} |
| 490 |
|
| 491 |
extern(C++) |
| 492 |
{ |
| 493 |
// Nspace |
| 494 |
std.allocator!int func_18957_1(std.allocator!(int)* v); |
| 495 |
// CPPNamespaceAttribute |
| 496 |
allocator!int func_18957_2(allocator!(int)* v); |
| 497 |
X func_18957_2(X)(X* v); |
| 498 |
} |
| 499 |
|
| 500 |
extern (C++) |
| 501 |
{ |
| 502 |
void func_20413(pair!(int, float), pair!(float, int)); |
| 503 |
} |
| 504 |
|
| 505 |
version (CppMangle_Itanium) |
| 506 |
{ |
| 507 |
// https://issues.dlang.org/show_bug.cgi?id=17947 |
| 508 |
static assert(std.pair!(void*, void*).swap.mangleof == "_ZNSt4pairIPvS0_E4swapERS1_"); |
| 509 |
static assert(std.allocator!int.fooa.mangleof == "_ZNKSaIiE4fooaEv"); |
| 510 |
static assert(std.allocator!int.foob.mangleof == "_ZNSaIiE4foobEv"); |
| 511 |
static assert(std.basic_string!(char,int,uint).fooa.mangleof == "_ZNSbIcijE4fooaEv"); |
| 512 |
static assert(std.basic_string!(char, std.char_traits!char, std.allocator!char).fooa.mangleof == "_ZNSs4fooaEv"); |
| 513 |
static assert(std.basic_istream!(char, std.char_traits!char).fooc.mangleof == "_ZNSi4foocEv"); |
| 514 |
static assert(std.basic_ostream!(char, std.char_traits!char).food.mangleof == "_ZNSo4foodEv"); |
| 515 |
static assert(std.basic_iostream!(char, std.char_traits!char).fooe.mangleof == "_ZNSd4fooeEv"); |
| 516 |
|
| 517 |
static assert(func_18957_1.mangleof == `_Z12func_18957_1PSaIiE`); |
| 518 |
static assert(func_18957_2!(std.allocator!int).mangleof == `_Z12func_18957_2ISaIiEET_PS1_`); |
| 519 |
|
| 520 |
|
| 521 |
static assert(pair!(void*, void*).swap.mangleof == "_ZNSt4pairIPvS0_E4swapERS1_"); |
| 522 |
static assert(allocator!int.fooa.mangleof == "_ZNKSaIiE4fooaEv"); |
| 523 |
static assert(allocator!int.foob.mangleof == "_ZNSaIiE4foobEv"); |
| 524 |
static assert(basic_string!(char,int,uint).fooa.mangleof == "_ZNSbIcijE4fooaEv"); |
| 525 |
static assert(basic_string!(char, char_traits!char, allocator!char).fooa.mangleof == "_ZNSs4fooaEv"); |
| 526 |
static assert(basic_istream!(char, char_traits!char).fooc.mangleof == "_ZNSi4foocEv"); |
| 527 |
static assert(basic_ostream!(char, char_traits!char).food.mangleof == "_ZNSo4foodEv"); |
| 528 |
static assert(basic_iostream!(char, char_traits!char).fooe.mangleof == "_ZNSd4fooeEv"); |
| 529 |
|
| 530 |
static assert(func_18957_2!(allocator!int).mangleof == `_Z12func_18957_2ISaIiEET_PS1_`); |
| 531 |
|
| 532 |
static assert(func_20413.mangleof == `_Z10func_20413St4pairIifES_IfiE`); |
| 533 |
} |
| 534 |
|
| 535 |
/**************************************/ |
| 536 |
|
| 537 |
alias T36 = int ********** ********** ********** **********; |
| 538 |
|
| 539 |
extern (C++) void test36(T36, T36*) { } |
| 540 |
|
| 541 |
version (CppMangle_Itanium) |
| 542 |
{ |
| 543 |
static assert(test36.mangleof == "_Z6test36PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPiPS12_"); |
| 544 |
} |
| 545 |
|
| 546 |
/*****************************************/ |
| 547 |
// https://issues.dlang.org/show_bug.cgi?id=17772 |
| 548 |
|
| 549 |
extern(C++, SPACE) |
| 550 |
int test37(T)(){ return 0;} |
| 551 |
|
| 552 |
extern(C++, `SPACE`) |
| 553 |
int test37(T)(){ return 0;} |
| 554 |
|
| 555 |
version (CppMangle_Itanium) // all non-Windows machines |
| 556 |
{ |
| 557 |
static assert(SPACE.test37!int.mangleof == "_ZN5SPACE6test37IiEEiv"); |
| 558 |
static assert(test37!int.mangleof == "_ZN5SPACE6test37IiEEiv"); |
| 559 |
} |
| 560 |
|
| 561 |
/**************************************/ |
| 562 |
// https://issues.dlang.org/show_bug.cgi?id=15388 |
| 563 |
|
| 564 |
extern (C++) void test15388(typeof(null)); |
| 565 |
|
| 566 |
version (CppMangle_Itanium) |
| 567 |
{ |
| 568 |
static assert(test15388.mangleof == "_Z9test15388Dn"); |
| 569 |
} |
| 570 |
version (CppMangle_MSVC) |
| 571 |
{ |
| 572 |
static assert(test15388.mangleof == "?test15388@@YAX$$T@Z"); |
| 573 |
} |
| 574 |
|
| 575 |
/**************************************/ |
| 576 |
// https://issues.dlang.org/show_bug.cgi?id=14086 |
| 577 |
|
| 578 |
extern (C++) class Test14086 |
| 579 |
{ |
| 580 |
this(); |
| 581 |
~this(); |
| 582 |
} |
| 583 |
extern (C++) class Test14086_2 |
| 584 |
{ |
| 585 |
final ~this(); |
| 586 |
} |
| 587 |
extern (C++) struct Test14086_S |
| 588 |
{ |
| 589 |
this(int); |
| 590 |
~this(); |
| 591 |
} |
| 592 |
|
| 593 |
version (CppMangle_Itanium) |
| 594 |
{ |
| 595 |
static assert(Test14086.__ctor.mangleof == "_ZN9Test14086C1Ev"); |
| 596 |
static assert(Test14086.__dtor.mangleof == "_ZN9Test14086D1Ev"); |
| 597 |
static assert(Test14086_2.__dtor.mangleof == "_ZN11Test14086_2D1Ev"); |
| 598 |
static assert(Test14086_S.__ctor.mangleof == "_ZN11Test14086_SC1Ei"); |
| 599 |
static assert(Test14086_S.__dtor.mangleof == "_ZN11Test14086_SD1Ev"); |
| 600 |
} |
| 601 |
version (CppMangle_MSVC) |
| 602 |
{ |
| 603 |
version (Win32) |
| 604 |
{ |
| 605 |
static assert(Test14086.__ctor.mangleof == "??0Test14086@@QAE@XZ"); |
| 606 |
static assert(Test14086.__dtor.mangleof == "??1Test14086@@UAE@XZ"); |
| 607 |
static assert(Test14086_2.__dtor.mangleof == "??1Test14086_2@@QAE@XZ"); |
| 608 |
static assert(Test14086_S.__ctor.mangleof == "??0Test14086_S@@QAE@H@Z"); |
| 609 |
static assert(Test14086_S.__dtor.mangleof == "??1Test14086_S@@QAE@XZ"); |
| 610 |
} |
| 611 |
version (Win64) |
| 612 |
{ |
| 613 |
static assert(Test14086.__ctor.mangleof == "??0Test14086@@QEAA@XZ"); |
| 614 |
static assert(Test14086.__dtor.mangleof == "??1Test14086@@UEAA@XZ"); |
| 615 |
static assert(Test14086_2.__dtor.mangleof == "??1Test14086_2@@QEAA@XZ"); |
| 616 |
static assert(Test14086_S.__ctor.mangleof == "??0Test14086_S@@QEAA@H@Z"); |
| 617 |
static assert(Test14086_S.__dtor.mangleof == "??1Test14086_S@@QEAA@XZ"); |
| 618 |
} |
| 619 |
} |
| 620 |
|
| 621 |
/**************************************/ |
| 622 |
// https://issues.dlang.org/show_bug.cgi?id=18888 |
| 623 |
|
| 624 |
extern (C++) |
| 625 |
struct T18888(T) |
| 626 |
{ |
| 627 |
void fun(); |
| 628 |
} |
| 629 |
|
| 630 |
extern (C++) |
| 631 |
struct S18888(alias arg = T18888) |
| 632 |
{ |
| 633 |
alias I = T18888!(arg!int); |
| 634 |
} |
| 635 |
|
| 636 |
version (CppMangle_Itanium) |
| 637 |
{ |
| 638 |
static assert(S18888!().I.fun.mangleof == "_ZN6T18888IS_IiEE3funEv"); |
| 639 |
} |
| 640 |
version (CppMangle_MSVC) |
| 641 |
{ |
| 642 |
version (Win32) |
| 643 |
{ |
| 644 |
static assert(S18888!().I.fun.mangleof == "?fun@?$T18888@U?$T18888@H@@@@QAEXXZ"); |
| 645 |
} |
| 646 |
version (Win64) |
| 647 |
{ |
| 648 |
static assert(S18888!().I.fun.mangleof == "?fun@?$T18888@U?$T18888@H@@@@QEAAXXZ"); |
| 649 |
} |
| 650 |
} |
| 651 |
|
| 652 |
/**************************************/ |
| 653 |
// https://issues.dlang.org/show_bug.cgi?id=18890 |
| 654 |
|
| 655 |
extern (C++) class C18890 |
| 656 |
{ |
| 657 |
~this() {} |
| 658 |
} |
| 659 |
extern (C++) class C18890_2 |
| 660 |
{ |
| 661 |
~this() {} |
| 662 |
extern (C++) struct Agg |
| 663 |
{ |
| 664 |
~this() {} |
| 665 |
} |
| 666 |
Agg s; |
| 667 |
} |
| 668 |
|
| 669 |
void test18890() |
| 670 |
{ |
| 671 |
version (CppMangle_Itanium) |
| 672 |
{ |
| 673 |
static assert(C18890.__dtor.mangleof == "_ZN6C18890D1Ev"); |
| 674 |
static assert(C18890.__xdtor.mangleof == "_ZN6C18890D1Ev"); |
| 675 |
static assert(C18890_2.__dtor.mangleof == "_ZN8C18890_26__dtorEv"); |
| 676 |
static assert(C18890_2.__xdtor.mangleof == "_ZN8C18890_2D1Ev"); |
| 677 |
} |
| 678 |
version (CppMangle_MSVC) |
| 679 |
{ |
| 680 |
version (Win32) |
| 681 |
{ |
| 682 |
static assert(C18890.__dtor.mangleof == "??1C18890@@UAE@XZ"); |
| 683 |
static assert(C18890.__xdtor.mangleof == "??_GC18890@@UAEPAXI@Z"); |
| 684 |
static assert(C18890_2.__dtor.mangleof == "?__dtor@C18890_2@@UAEXXZ"); |
| 685 |
static assert(C18890_2.__xdtor.mangleof == "??_GC18890_2@@UAEPAXI@Z"); |
| 686 |
} |
| 687 |
version (Win64) |
| 688 |
{ |
| 689 |
static assert(C18890.__dtor.mangleof == "??1C18890@@UEAA@XZ"); |
| 690 |
static assert(C18890.__xdtor.mangleof == "??_GC18890@@UEAAPEAXI@Z"); |
| 691 |
static assert(C18890_2.__dtor.mangleof == "?__dtor@C18890_2@@UEAAXXZ"); |
| 692 |
static assert(C18890_2.__xdtor.mangleof == "??_GC18890_2@@UEAAPEAXI@Z"); |
| 693 |
} |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
/**************************************/ |
| 698 |
// https://issues.dlang.org/show_bug.cgi?id=18891 |
| 699 |
|
| 700 |
extern (C++) class C18891 |
| 701 |
{ |
| 702 |
~this(); |
| 703 |
extern (C++) struct Agg |
| 704 |
{ |
| 705 |
~this() {} |
| 706 |
} |
| 707 |
Agg s; |
| 708 |
} |
| 709 |
|
| 710 |
void test18891() |
| 711 |
{ |
| 712 |
version (CppMangle_Itanium) |
| 713 |
{ |
| 714 |
static assert(C18891.__dtor.mangleof == "_ZN6C18891D1Ev"); |
| 715 |
static assert(C18891.__xdtor.mangleof == "_ZN6C18891D1Ev"); |
| 716 |
} |
| 717 |
version (CppMangle_MSVC) |
| 718 |
{ |
| 719 |
version (Win32) |
| 720 |
{ |
| 721 |
static assert(C18891.__dtor.mangleof == "??1C18891@@UAE@XZ"); |
| 722 |
static assert(C18891.__xdtor.mangleof == "??_GC18891@@UAEPAXI@Z"); |
| 723 |
} |
| 724 |
version (Win64) |
| 725 |
{ |
| 726 |
static assert(C18891.__dtor.mangleof == "??1C18891@@UEAA@XZ"); |
| 727 |
static assert(C18891.__xdtor.mangleof == "??_GC18891@@UEAAPEAXI@Z"); |
| 728 |
} |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
/**************************************/ |
| 733 |
// Test C++ operator mangling |
| 734 |
|
| 735 |
extern (C++) struct TestOperators |
| 736 |
{ |
| 737 |
int opCast(T)(); |
| 738 |
int opBinary(string op)(int x); |
| 739 |
int opUnary(string op)(); |
| 740 |
int opOpAssign(string op)(int x); |
| 741 |
int opIndex(int x); |
| 742 |
bool opEquals(int x); |
| 743 |
int opCall(int, float); |
| 744 |
int opAssign(int); |
| 745 |
} |
| 746 |
|
| 747 |
version (CppMangle_Itanium) |
| 748 |
{ |
| 749 |
static assert(TestOperators.opUnary!"*".mangleof == "_ZN13TestOperatorsdeEv"); |
| 750 |
static assert(TestOperators.opUnary!"++".mangleof == "_ZN13TestOperatorsppEv"); |
| 751 |
static assert(TestOperators.opUnary!"--".mangleof == "_ZN13TestOperatorsmmEv"); |
| 752 |
static assert(TestOperators.opUnary!"-".mangleof == "_ZN13TestOperatorsngEv"); |
| 753 |
static assert(TestOperators.opUnary!"+".mangleof == "_ZN13TestOperatorspsEv"); |
| 754 |
static assert(TestOperators.opUnary!"~".mangleof == "_ZN13TestOperatorscoEv"); |
| 755 |
static assert(TestOperators.opBinary!">>".mangleof == "_ZN13TestOperatorsrsEi"); |
| 756 |
static assert(TestOperators.opBinary!"<<".mangleof == "_ZN13TestOperatorslsEi"); |
| 757 |
static assert(TestOperators.opBinary!"*".mangleof == "_ZN13TestOperatorsmlEi"); |
| 758 |
static assert(TestOperators.opBinary!"-".mangleof == "_ZN13TestOperatorsmiEi"); |
| 759 |
static assert(TestOperators.opBinary!"+".mangleof == "_ZN13TestOperatorsplEi"); |
| 760 |
static assert(TestOperators.opBinary!"&".mangleof == "_ZN13TestOperatorsanEi"); |
| 761 |
static assert(TestOperators.opBinary!"/".mangleof == "_ZN13TestOperatorsdvEi"); |
| 762 |
static assert(TestOperators.opBinary!"%".mangleof == "_ZN13TestOperatorsrmEi"); |
| 763 |
static assert(TestOperators.opBinary!"^".mangleof == "_ZN13TestOperatorseoEi"); |
| 764 |
static assert(TestOperators.opBinary!"|".mangleof == "_ZN13TestOperatorsorEi"); |
| 765 |
static assert(TestOperators.opOpAssign!"*".mangleof == "_ZN13TestOperatorsmLEi"); |
| 766 |
static assert(TestOperators.opOpAssign!"+".mangleof == "_ZN13TestOperatorspLEi"); |
| 767 |
static assert(TestOperators.opOpAssign!"-".mangleof == "_ZN13TestOperatorsmIEi"); |
| 768 |
static assert(TestOperators.opOpAssign!"/".mangleof == "_ZN13TestOperatorsdVEi"); |
| 769 |
static assert(TestOperators.opOpAssign!"%".mangleof == "_ZN13TestOperatorsrMEi"); |
| 770 |
static assert(TestOperators.opOpAssign!">>".mangleof == "_ZN13TestOperatorsrSEi"); |
| 771 |
static assert(TestOperators.opOpAssign!"<<".mangleof == "_ZN13TestOperatorslSEi"); |
| 772 |
static assert(TestOperators.opOpAssign!"&".mangleof == "_ZN13TestOperatorsaNEi"); |
| 773 |
static assert(TestOperators.opOpAssign!"|".mangleof == "_ZN13TestOperatorsoREi"); |
| 774 |
static assert(TestOperators.opOpAssign!"^".mangleof == "_ZN13TestOperatorseOEi"); |
| 775 |
static assert(TestOperators.opCast!int.mangleof == "_ZN13TestOperatorscviEv"); |
| 776 |
static assert(TestOperators.opAssign.mangleof == "_ZN13TestOperatorsaSEi"); |
| 777 |
static assert(TestOperators.opEquals.mangleof == "_ZN13TestOperatorseqEi"); |
| 778 |
static assert(TestOperators.opIndex.mangleof == "_ZN13TestOperatorsixEi"); |
| 779 |
static assert(TestOperators.opCall.mangleof == "_ZN13TestOperatorsclEif"); |
| 780 |
} |
| 781 |
version (CppMangle_MSVC) |
| 782 |
{ |
| 783 |
version (Win32) |
| 784 |
{ |
| 785 |
static assert(TestOperators.opUnary!"*".mangleof == "??DTestOperators@@QAEHXZ"); |
| 786 |
static assert(TestOperators.opUnary!"++".mangleof == "??ETestOperators@@QAEHXZ"); |
| 787 |
static assert(TestOperators.opUnary!"--".mangleof == "??FTestOperators@@QAEHXZ"); |
| 788 |
static assert(TestOperators.opUnary!"-".mangleof == "??GTestOperators@@QAEHXZ"); |
| 789 |
static assert(TestOperators.opUnary!"+".mangleof == "??HTestOperators@@QAEHXZ"); |
| 790 |
static assert(TestOperators.opUnary!"~".mangleof == "??STestOperators@@QAEHXZ"); |
| 791 |
static assert(TestOperators.opBinary!">>".mangleof == "??5TestOperators@@QAEHH@Z"); |
| 792 |
static assert(TestOperators.opBinary!"<<".mangleof == "??6TestOperators@@QAEHH@Z"); |
| 793 |
static assert(TestOperators.opBinary!"*".mangleof == "??DTestOperators@@QAEHH@Z"); |
| 794 |
static assert(TestOperators.opBinary!"-".mangleof == "??GTestOperators@@QAEHH@Z"); |
| 795 |
static assert(TestOperators.opBinary!"+".mangleof == "??HTestOperators@@QAEHH@Z"); |
| 796 |
static assert(TestOperators.opBinary!"&".mangleof == "??ITestOperators@@QAEHH@Z"); |
| 797 |
static assert(TestOperators.opBinary!"/".mangleof == "??KTestOperators@@QAEHH@Z"); |
| 798 |
static assert(TestOperators.opBinary!"%".mangleof == "??LTestOperators@@QAEHH@Z"); |
| 799 |
static assert(TestOperators.opBinary!"^".mangleof == "??TTestOperators@@QAEHH@Z"); |
| 800 |
static assert(TestOperators.opBinary!"|".mangleof == "??UTestOperators@@QAEHH@Z"); |
| 801 |
static assert(TestOperators.opOpAssign!"*".mangleof == "??XTestOperators@@QAEHH@Z"); |
| 802 |
static assert(TestOperators.opOpAssign!"+".mangleof == "??YTestOperators@@QAEHH@Z"); |
| 803 |
static assert(TestOperators.opOpAssign!"-".mangleof == "??ZTestOperators@@QAEHH@Z"); |
| 804 |
static assert(TestOperators.opOpAssign!"/".mangleof == "??_0TestOperators@@QAEHH@Z"); |
| 805 |
static assert(TestOperators.opOpAssign!"%".mangleof == "??_1TestOperators@@QAEHH@Z"); |
| 806 |
static assert(TestOperators.opOpAssign!">>".mangleof == "??_2TestOperators@@QAEHH@Z"); |
| 807 |
static assert(TestOperators.opOpAssign!"<<".mangleof == "??_3TestOperators@@QAEHH@Z"); |
| 808 |
static assert(TestOperators.opOpAssign!"&".mangleof == "??_4TestOperators@@QAEHH@Z"); |
| 809 |
static assert(TestOperators.opOpAssign!"|".mangleof == "??_5TestOperators@@QAEHH@Z"); |
| 810 |
static assert(TestOperators.opOpAssign!"^".mangleof == "??_6TestOperators@@QAEHH@Z"); |
| 811 |
static assert(TestOperators.opCast!int.mangleof == "??BTestOperators@@QAEHXZ"); |
| 812 |
static assert(TestOperators.opAssign.mangleof == "??4TestOperators@@QAEHH@Z"); |
| 813 |
static assert(TestOperators.opEquals.mangleof == "??8TestOperators@@QAE_NH@Z"); |
| 814 |
static assert(TestOperators.opIndex.mangleof == "??ATestOperators@@QAEHH@Z"); |
| 815 |
static assert(TestOperators.opCall.mangleof == "??RTestOperators@@QAEHHM@Z"); |
| 816 |
} |
| 817 |
version (Win64) |
| 818 |
{ |
| 819 |
static assert(TestOperators.opUnary!"*".mangleof == "??DTestOperators@@QEAAHXZ"); |
| 820 |
static assert(TestOperators.opUnary!"++".mangleof == "??ETestOperators@@QEAAHXZ"); |
| 821 |
static assert(TestOperators.opUnary!"--".mangleof == "??FTestOperators@@QEAAHXZ"); |
| 822 |
static assert(TestOperators.opUnary!"-".mangleof == "??GTestOperators@@QEAAHXZ"); |
| 823 |
static assert(TestOperators.opUnary!"+".mangleof == "??HTestOperators@@QEAAHXZ"); |
| 824 |
static assert(TestOperators.opUnary!"~".mangleof == "??STestOperators@@QEAAHXZ"); |
| 825 |
static assert(TestOperators.opBinary!">>".mangleof == "??5TestOperators@@QEAAHH@Z"); |
| 826 |
static assert(TestOperators.opBinary!"<<".mangleof == "??6TestOperators@@QEAAHH@Z"); |
| 827 |
static assert(TestOperators.opBinary!"*".mangleof == "??DTestOperators@@QEAAHH@Z"); |
| 828 |
static assert(TestOperators.opBinary!"-".mangleof == "??GTestOperators@@QEAAHH@Z"); |
| 829 |
static assert(TestOperators.opBinary!"+".mangleof == "??HTestOperators@@QEAAHH@Z"); |
| 830 |
static assert(TestOperators.opBinary!"&".mangleof == "??ITestOperators@@QEAAHH@Z"); |
| 831 |
static assert(TestOperators.opBinary!"/".mangleof == "??KTestOperators@@QEAAHH@Z"); |
| 832 |
static assert(TestOperators.opBinary!"%".mangleof == "??LTestOperators@@QEAAHH@Z"); |
| 833 |
static assert(TestOperators.opBinary!"^".mangleof == "??TTestOperators@@QEAAHH@Z"); |
| 834 |
static assert(TestOperators.opBinary!"|".mangleof == "??UTestOperators@@QEAAHH@Z"); |
| 835 |
static assert(TestOperators.opOpAssign!"*".mangleof == "??XTestOperators@@QEAAHH@Z"); |
| 836 |
static assert(TestOperators.opOpAssign!"+".mangleof == "??YTestOperators@@QEAAHH@Z"); |
| 837 |
static assert(TestOperators.opOpAssign!"-".mangleof == "??ZTestOperators@@QEAAHH@Z"); |
| 838 |
static assert(TestOperators.opOpAssign!"/".mangleof == "??_0TestOperators@@QEAAHH@Z"); |
| 839 |
static assert(TestOperators.opOpAssign!"%".mangleof == "??_1TestOperators@@QEAAHH@Z"); |
| 840 |
static assert(TestOperators.opOpAssign!">>".mangleof == "??_2TestOperators@@QEAAHH@Z"); |
| 841 |
static assert(TestOperators.opOpAssign!"<<".mangleof == "??_3TestOperators@@QEAAHH@Z"); |
| 842 |
static assert(TestOperators.opOpAssign!"&".mangleof == "??_4TestOperators@@QEAAHH@Z"); |
| 843 |
static assert(TestOperators.opOpAssign!"|".mangleof == "??_5TestOperators@@QEAAHH@Z"); |
| 844 |
static assert(TestOperators.opOpAssign!"^".mangleof == "??_6TestOperators@@QEAAHH@Z"); |
| 845 |
static assert(TestOperators.opCast!int.mangleof == "??BTestOperators@@QEAAHXZ"); |
| 846 |
static assert(TestOperators.opAssign.mangleof == "??4TestOperators@@QEAAHH@Z"); |
| 847 |
static assert(TestOperators.opEquals.mangleof == "??8TestOperators@@QEAA_NH@Z"); |
| 848 |
static assert(TestOperators.opIndex.mangleof == "??ATestOperators@@QEAAHH@Z"); |
| 849 |
static assert(TestOperators.opCall.mangleof == "??RTestOperators@@QEAAHHM@Z"); |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
import cppmangle2; |
| 854 |
extern(C++, Namespace18922) |
| 855 |
{ |
| 856 |
// Nspace |
| 857 |
void func18922(cppmangle2.Namespace18922.Struct18922) {} |
| 858 |
// CPPNamespaceAttribute |
| 859 |
void func18922_1(Struct18922) {} |
| 860 |
} |
| 861 |
|
| 862 |
extern(C++, `Namespace18922`) |
| 863 |
{ |
| 864 |
// Nspace |
| 865 |
void func18922_2(cppmangle2.Namespace18922.Struct18922) {} |
| 866 |
// CPPNamespaceAttribute |
| 867 |
void func18922_3(Struct18922) {} |
| 868 |
} |
| 869 |
|
| 870 |
version (CppMangle_Itanium) |
| 871 |
{ |
| 872 |
static assert(func18922.mangleof == "_ZN14Namespace189229func18922ENS_11Struct18922E"); |
| 873 |
static assert(func18922_1.mangleof == "_ZN14Namespace1892211func18922_1ENS_11Struct18922E"); |
| 874 |
static assert(func18922_2.mangleof == "_ZN14Namespace1892211func18922_2ENS_11Struct18922E"); |
| 875 |
static assert(func18922_3.mangleof == "_ZN14Namespace1892211func18922_3ENS_11Struct18922E"); |
| 876 |
} |
| 877 |
else version (CppMangle_MSVC) |
| 878 |
{ |
| 879 |
static assert(func18922.mangleof == "?func18922@Namespace18922@@YAXUStruct18922@1@@Z"); |
| 880 |
static assert(func18922_1.mangleof == "?func18922_1@Namespace18922@@YAXUStruct18922@1@@Z"); |
| 881 |
static assert(func18922_2.mangleof == "?func18922_2@Namespace18922@@YAXUStruct18922@1@@Z"); |
| 882 |
static assert(func18922_3.mangleof == "?func18922_3@Namespace18922@@YAXUStruct18922@1@@Z"); |
| 883 |
} |
| 884 |
|
| 885 |
/**************************************/ |
| 886 |
// https://issues.dlang.org/show_bug.cgi?id=18957 |
| 887 |
// extern(C++) doesn't mangle 'std' correctly on posix systems |
| 888 |
|
| 889 |
version (CppMangle_Itanium) |
| 890 |
{ |
| 891 |
// https://godbolt.org/z/C5T2LQ |
| 892 |
/+ |
| 893 |
namespace std |
| 894 |
{ |
| 895 |
struct test18957 {}; |
| 896 |
} |
| 897 |
void test18957(const std::test18957& t) {} |
| 898 |
+/ |
| 899 |
extern (C++) void test18957(ref const(Struct18957) t) {} |
| 900 |
|
| 901 |
static assert(test18957.mangleof == "_Z9test18957RKSt11Struct18957"); |
| 902 |
} |
| 903 |
|
| 904 |
/**************************************/ |
| 905 |
// https://issues.dlang.org/show_bug.cgi?id=19043 |
| 906 |
// Incorrect mangling for extern(C++) const template parameter on windows |
| 907 |
|
| 908 |
extern(C++) struct test19043(T) {} |
| 909 |
|
| 910 |
extern(C++) void test19043a(test19043!(const(char)) a) {} |
| 911 |
extern(C++) void test19043b(T)(T a) {} |
| 912 |
version (CppMangle_MSVC) |
| 913 |
{ |
| 914 |
static assert(test19043a.mangleof == "?test19043a@@YAXU?$test19043@$$CBD@@@Z"); |
| 915 |
static assert(test19043b!(test19043!(const(char))).mangleof == |
| 916 |
"??$test19043b@U?$test19043@$$CBD@@@@YAXU?$test19043@$$CBD@@@Z"); |
| 917 |
} |
| 918 |
|
| 919 |
// https://issues.dlang.org/show_bug.cgi?id=16479 |
| 920 |
// Missing substitution while mangling C++ template parameter for functions |
| 921 |
version (CppMangle_Itanium) extern (C++) |
| 922 |
{ |
| 923 |
// Make sure aliases are still resolved |
| 924 |
alias Alias16479 = int; |
| 925 |
Alias16479 func16479_0 (FuncT1) (FuncT1, Alias16479); |
| 926 |
static assert(func16479_0!(int).mangleof == `_Z11func16479_0IiEiT_i`); |
| 927 |
|
| 928 |
// Simple substitution on return type |
| 929 |
FuncT1* func16479_1 (FuncT1) (); |
| 930 |
static assert(func16479_1!(int).mangleof == `_Z11func16479_1IiEPT_v`); |
| 931 |
|
| 932 |
// Simple substitution on parameter |
| 933 |
void func16479_2 (FuncT1) (FuncT1); |
| 934 |
static assert(func16479_2!(int).mangleof == `_Z11func16479_2IiEvT_`); |
| 935 |
|
| 936 |
// Make sure component substition is prefered over template parameter |
| 937 |
FuncT1* func16479_3 (FuncT1) (FuncT1); |
| 938 |
static assert(func16479_3!(int).mangleof == `_Z11func16479_3IiEPT_S0_`); |
| 939 |
|
| 940 |
struct Array16479 (Arg) { Arg* data; } |
| 941 |
struct Array16479_2 (Arg, int Size) { Arg[Size] data; } |
| 942 |
struct Value16479 (int Value1, int Value2) { int data; } |
| 943 |
|
| 944 |
// Make sure template parameter substitution happens on templated return |
| 945 |
Array16479!(FuncT2) func16479_4 (FuncT1, FuncT2) (FuncT1); |
| 946 |
static assert(func16479_4!(int, float).mangleof |
| 947 |
== `_Z11func16479_4IifE10Array16479IT0_ET_`); |
| 948 |
|
| 949 |
// Make sure template parameter substitution happens with values |
| 950 |
Value16479!(Value2, Value1)* func16479_5 (int Value1, int Value2) (); |
| 951 |
static assert(func16479_5!(1, 1).mangleof |
| 952 |
== `_Z11func16479_5ILi1ELi1EEP10Value16479IXT0_EXT_EEv`); |
| 953 |
|
| 954 |
// But make sure it's not substituting *too many* values |
| 955 |
Value16479!(1, 1)* func16479_6 (int Value1, int Value2) (); |
| 956 |
static assert(func16479_6!(1, 1).mangleof |
| 957 |
== `_Z11func16479_6ILi1ELi1EEP10Value16479ILi1ELi1EEv`); |
| 958 |
|
| 959 |
// Or too many types |
| 960 |
Array16479!(int) func16479_7 (FuncT1, FuncT2) (FuncT1); |
| 961 |
static assert(func16479_7!(int, int).mangleof |
| 962 |
== `_Z11func16479_7IiiE10Array16479IiET_`); |
| 963 |
|
| 964 |
// Also must check the parameters for template param substitution |
| 965 |
void func16479_8 (FuncT1) (Array16479!(FuncT1)); |
| 966 |
static assert(func16479_8!(int).mangleof |
| 967 |
== `_Z11func16479_8IiEv10Array16479IT_E`); |
| 968 |
|
| 969 |
// And non-substitution |
| 970 |
void func16479_9 (FuncT1) (Array16479!(int)); |
| 971 |
static assert(func16479_9!(int).mangleof |
| 972 |
== `_Z11func16479_9IiEv10Array16479IiE`); |
| 973 |
|
| 974 |
// Now let's have a bit of fun with alias parameters, |
| 975 |
// starting with C functions |
| 976 |
// TODO: Why is this mangled by g++: |
| 977 |
/* |
| 978 |
extern "C" |
| 979 |
{ |
| 980 |
void externC16479 (int); |
| 981 |
} |
| 982 |
|
| 983 |
template<void (*Print)(int)> |
| 984 |
void func16479_10 (); |
| 985 |
|
| 986 |
void foo () { func16479_10<externC16479>(); } |
| 987 |
*/ |
| 988 |
extern (C) void externC16479 (int); |
| 989 |
void func16479_10 (alias Print) (); |
| 990 |
static assert(func16479_10!(externC16479).mangleof |
| 991 |
== `_Z12func16479_10IXadL_Z12externC16479EEEvv`); |
| 992 |
|
| 993 |
/** |
| 994 |
* Let's not exclude C++ functions |
| 995 |
* Note: |
| 996 |
* Passing a function as template parameter has an implicit |
| 997 |
* `&` operator prepended to it, so the following code: |
| 998 |
* --- |
| 999 |
* void CPPPrinter16479(const char*); |
| 1000 |
* template<void (*Print)(const char*)> void func16479_11 (); |
| 1001 |
* void foo () { func16479_11<CPPPrinter16479>(); } |
| 1002 |
* --- |
| 1003 |
* Gets mangled as `func16479_11<&CPPPrinter16479>()` would, |
| 1004 |
* which means the expression part of the template argument is |
| 1005 |
* mangled as `XadL_Z[...]E` not `XL_Z[...]E` |
| 1006 |
* (expressions always begin with a code anyway). |
| 1007 |
*/ |
| 1008 |
extern(C++) void CPPPrinter16479(const(char)*); |
| 1009 |
extern(C++, Namespace16479) void CPPPrinterNS16479(const(char)*); |
| 1010 |
extern(C++, `Namespace16479`) void CPPPrinterNS16479_1(const(char)*); |
| 1011 |
void func16479_11 (alias Print) (); |
| 1012 |
static assert(func16479_11!(CPPPrinter16479).mangleof |
| 1013 |
== `_Z12func16479_11IXadL_Z15CPPPrinter16479PKcEEEvv`); |
| 1014 |
static assert(func16479_11!(CPPPrinterNS16479).mangleof |
| 1015 |
== `_Z12func16479_11IXadL_ZN14Namespace1647917CPPPrinterNS16479EPKcEEEvv`); |
| 1016 |
static assert(func16479_11!(CPPPrinterNS16479_1).mangleof |
| 1017 |
== `_Z12func16479_11IXadL_ZN14Namespace1647919CPPPrinterNS16479_1EPKcEEEvv`); |
| 1018 |
|
| 1019 |
// Functions are fine, but templates are finer |
| 1020 |
// --- |
| 1021 |
// template<template<typename, int> class Container, typename T, int Val> |
| 1022 |
// Container<T, Val> func16479_12 (); |
| 1023 |
// --- |
| 1024 |
Container!(T, Val) func16479_12 (alias Container, T, int Val) (); |
| 1025 |
static assert(func16479_12!(Array16479_2, int, 42).mangleof |
| 1026 |
== `_Z12func16479_12I12Array16479_2iLi42EET_IT0_XT1_EEv`); |
| 1027 |
|
| 1028 |
// Substitution needs to happen on the most specialized type |
| 1029 |
// Iow, `ref T identity (T) (ref T v);` should be mangled as |
| 1030 |
// `_Z8identityIiET_*S1_*`, not as `_Z8identityIiET_*RS0_*` |
| 1031 |
ref FuncT1 func16479_13_1 (FuncT1) (ref FuncT1); |
| 1032 |
FuncT1* func16479_13_2 (FuncT1) (FuncT1*); |
| 1033 |
void func16479_13_3 (FuncT1) (FuncT1*, FuncT1*); |
| 1034 |
FuncT1** func16479_13_4 (FuncT1) (FuncT1*, FuncT1); |
| 1035 |
FuncT1 func16479_13_5 (FuncT1) (FuncT1*, FuncT1**); |
| 1036 |
static assert(func16479_13_1!(int).mangleof == `_Z14func16479_13_1IiERT_S1_`); |
| 1037 |
static assert(func16479_13_2!(float).mangleof == `_Z14func16479_13_2IfEPT_S1_`); |
| 1038 |
static assert(func16479_13_3!(int).mangleof == `_Z14func16479_13_3IiEvPT_S1_`); |
| 1039 |
static assert(func16479_13_4!(int).mangleof == `_Z14func16479_13_4IiEPPT_S1_S0_`); |
| 1040 |
static assert(func16479_13_5!(int).mangleof == `_Z14func16479_13_5IiET_PS0_PS1_`); |
| 1041 |
|
| 1042 |
// Opaque types result in a slightly different AST |
| 1043 |
vector!T* func16479_14 (T) (T v); |
| 1044 |
static assert(func16479_14!(int).mangleof == `_Z12func16479_14IiEPSt6vectorIT_ES1_`); |
| 1045 |
|
| 1046 |
struct Foo16479_15 (T); |
| 1047 |
struct Baguette16479_15 (T); |
| 1048 |
struct Bar16479_15 (T); |
| 1049 |
struct FooBar16479_15 (A, B); |
| 1050 |
void inst16479_15_2 (A, B) (); |
| 1051 |
void inst16479_15_3 (A, B, C) (); |
| 1052 |
|
| 1053 |
static assert(inst16479_15_2!(Bar16479_15!int, int).mangleof |
| 1054 |
== `_Z14inst16479_15_2I11Bar16479_15IiEiEvv`); |
| 1055 |
static assert(inst16479_15_2!(int, Bar16479_15!int).mangleof |
| 1056 |
== `_Z14inst16479_15_2Ii11Bar16479_15IiEEvv`); |
| 1057 |
static assert(inst16479_15_2!(Bar16479_15!int, FooBar16479_15!(Bar16479_15!int, Foo16479_15!(Bar16479_15!(Foo16479_15!int)))).mangleof |
| 1058 |
== `_Z14inst16479_15_2I11Bar16479_15IiE14FooBar16479_15IS1_11Foo16479_15IS0_IS3_IiEEEEEvv`); |
| 1059 |
static assert(inst16479_15_3!(int, Bar16479_15!int, FooBar16479_15!(Bar16479_15!int, Foo16479_15!(Bar16479_15!(Foo16479_15!int)))).mangleof |
| 1060 |
== `_Z14inst16479_15_3Ii11Bar16479_15IiE14FooBar16479_15IS1_11Foo16479_15IS0_IS3_IiEEEEEvv`); |
| 1061 |
|
| 1062 |
static import cppmangle2; |
| 1063 |
cppmangle2.Struct18922* func16479_16_1 (T) (T*); |
| 1064 |
static assert(func16479_16_1!int.mangleof == `_Z14func16479_16_1IiEPN14Namespace1892211Struct18922EPT_`); |
| 1065 |
T* func16479_16_2 (T) (T*); |
| 1066 |
static assert(func16479_16_2!int.mangleof == `_Z14func16479_16_2IiEPT_S1_`); |
| 1067 |
static assert(func16479_16_2!(cppmangle2.vector!int).mangleof == `_Z14func16479_16_2ISt6vectorIiEEPT_S3_`); |
| 1068 |
static assert(func16479_16_2!(cppmangle2.vector!int).mangleof |
| 1069 |
== func16479_16_2!(cppmangle2.vector!int).mangleof); |
| 1070 |
cppmangle2.vector!T* func16479_16_3 (T) (T*); |
| 1071 |
static assert(func16479_16_3!int.mangleof == `_Z14func16479_16_3IiEPSt6vectorIiEPT_`); |
| 1072 |
|
| 1073 |
extern(C++, `fakestd`) { |
| 1074 |
extern (C++, `__1`) { |
| 1075 |
struct allocator16479 (T); |
| 1076 |
struct vector16479(T, alloc = allocator16479!T); |
| 1077 |
} |
| 1078 |
} |
| 1079 |
vector16479!(T, allocator16479!T)* func16479_17_1(T)(); |
| 1080 |
vector16479!(T)* func16479_17_2(T)(); |
| 1081 |
static assert(func16479_17_1!int.mangleof == `_Z14func16479_17_1IiEPN7fakestd3__111vector16479IT_NS1_14allocator16479IS3_EEEEv`); |
| 1082 |
static assert(func16479_17_2!int.mangleof == `_Z14func16479_17_2IiEPN7fakestd3__111vector16479IT_NS1_14allocator16479IS3_EEEEv`); |
| 1083 |
|
| 1084 |
// Make sure substitution takes place everywhere in template arg list |
| 1085 |
extern(C++, "ns") void func16479_18_1(T, X)(int, X, T, float); |
| 1086 |
extern(C++, "ns") void func16479_18_2(T, X)(X, int, T, float); |
| 1087 |
static assert(func16479_18_1!(double, char).mangleof == `_ZN2ns14func16479_18_1IdcEEviT0_T_f`); |
| 1088 |
static assert(func16479_18_2!(double, char).mangleof == `_ZN2ns14func16479_18_2IdcEEvT0_iT_f`); |
| 1089 |
} |
| 1090 |
|
| 1091 |
/**************************************/ |
| 1092 |
// https://issues.dlang.org/show_bug.cgi?id=19278 |
| 1093 |
// extern(C++, "name") doesn't accept expressions |
| 1094 |
|
| 1095 |
extern(C++, "hello" ~ "world") |
| 1096 |
{ |
| 1097 |
void test19278(); |
| 1098 |
} |
| 1099 |
enum NS = "lookup"; |
| 1100 |
extern(C++, (NS)) |
| 1101 |
{ |
| 1102 |
void test19278_2(); |
| 1103 |
} |
| 1104 |
alias AliasSeq(Args...) = Args; |
| 1105 |
alias Tup = AliasSeq!("hello", "world"); |
| 1106 |
extern(C++, (Tup)) |
| 1107 |
{ |
| 1108 |
void test19278_3(); |
| 1109 |
__gshared size_t test19278_var; |
| 1110 |
} |
| 1111 |
extern(C++, (AliasSeq!(Tup, "yay"))) |
| 1112 |
{ |
| 1113 |
void test19278_4(); |
| 1114 |
} |
| 1115 |
version (CppMangle_MSVC) |
| 1116 |
{ |
| 1117 |
version (Win64) |
| 1118 |
{ |
| 1119 |
static assert(test19278.mangleof == "?test19278@helloworld@@YAXXZ"); |
| 1120 |
static assert(test19278_2.mangleof == "?test19278_2@lookup@@YAXXZ"); |
| 1121 |
static assert(test19278_3.mangleof == "?test19278_3@world@hello@@YAXXZ"); |
| 1122 |
static assert(test19278_4.mangleof == "?test19278_4@yay@world@hello@@YAXXZ"); |
| 1123 |
static assert(test19278_var.mangleof == "?test19278_var@world@hello@@3_KA"); |
| 1124 |
} |
| 1125 |
} |
| 1126 |
else version (CppMangle_Itanium) |
| 1127 |
{ |
| 1128 |
static assert(test19278.mangleof == "_ZN10helloworld9test19278Ev"); |
| 1129 |
static assert(test19278_2.mangleof == "_ZN6lookup11test19278_2Ev"); |
| 1130 |
static assert(test19278_3.mangleof == "_ZN5hello5world11test19278_3Ev"); |
| 1131 |
static assert(test19278_4.mangleof == "_ZN5hello5world3yay11test19278_4Ev"); |
| 1132 |
static assert(test19278_var.mangleof == "_ZN5hello5world13test19278_varE"); |
| 1133 |
} |
| 1134 |
|
| 1135 |
/**************************************/ |
| 1136 |
// https://issues.dlang.org/show_bug.cgi?id=18958 |
| 1137 |
// Issue 18958 - extern(C++) wchar, dchar mangling not correct |
| 1138 |
|
| 1139 |
version (Posix) |
| 1140 |
enum __c_wchar_t : dchar; |
| 1141 |
else version (Windows) |
| 1142 |
enum __c_wchar_t : wchar; |
| 1143 |
alias wchar_t = __c_wchar_t; |
| 1144 |
extern (C++) void test_char_mangling(char, wchar, dchar, wchar_t); |
| 1145 |
version (CppMangle_Itanium) |
| 1146 |
{ |
| 1147 |
static assert(test_char_mangling.mangleof == "_Z18test_char_manglingcDsDiw"); |
| 1148 |
} |
| 1149 |
version (CppMangle_MSVC) |
| 1150 |
{ |
| 1151 |
version (Win64) |
| 1152 |
{ |
| 1153 |
static assert(test_char_mangling.mangleof == "?test_char_mangling@@YAXD_S_U_W@Z"); |
| 1154 |
} |
| 1155 |
} |
| 1156 |
|
| 1157 |
// https://github.com/dlang/dmd/pull/10021/files#r294055424 |
| 1158 |
version (CppMangle_Itanium) |
| 1159 |
{ |
| 1160 |
extern(C++, PR10021_NS) struct PR10021_Struct(T){} |
| 1161 |
extern(C++) void PR10021_fun(int i)(PR10021_Struct!int); |
| 1162 |
static assert(PR10021_fun!0.mangleof == `_Z11PR10021_funILi0EEvN10PR10021_NS14PR10021_StructIiEE`); |
| 1163 |
} |
| 1164 |
|
| 1165 |
// https://github.com/dlang/dmd/pull/10021#discussion_r294095749 |
| 1166 |
version (CppMangle_Itanium) |
| 1167 |
{ |
| 1168 |
extern(C++, "a", "b") |
| 1169 |
struct PR10021_Struct2 |
| 1170 |
{ |
| 1171 |
void func(); |
| 1172 |
void func2(PR10021_Struct2*); |
| 1173 |
} |
| 1174 |
static assert(PR10021_Struct2.func.mangleof == `_ZN1a1b15PR10021_Struct24funcEv`); |
| 1175 |
static assert(PR10021_Struct2.func2.mangleof == `_ZN1a1b15PR10021_Struct25func2EPS1_`); |
| 1176 |
} |
| 1177 |
|
| 1178 |
/// https://issues.dlang.org/show_bug.cgi?id=20022 |
| 1179 |
version (CppMangle_Itanium) |
| 1180 |
{ |
| 1181 |
extern(C++, `ns20022`) enum Enum20022_1 { A = 1, } |
| 1182 |
extern(C++) void fun20022_1(Enum20022_1); |
| 1183 |
extern(C++, `ns20022`) void fun20022_2(Enum20022_1); |
| 1184 |
|
| 1185 |
extern(C++, ns20022) |
| 1186 |
{ |
| 1187 |
enum Enum20022_2 { A = 1, } |
| 1188 |
void fun20022_5(Enum20022_1); |
| 1189 |
void fun20022_6(Enum20022_2); |
| 1190 |
} |
| 1191 |
extern(C++) void fun20022_3(Enum20022_2); |
| 1192 |
extern(C++, `ns20022`) void fun20022_4(Enum20022_2); |
| 1193 |
|
| 1194 |
static assert(fun20022_1.mangleof == `_Z10fun20022_1N7ns2002211Enum20022_1E`); |
| 1195 |
static assert(fun20022_2.mangleof == `_ZN7ns2002210fun20022_2ENS_11Enum20022_1E`); |
| 1196 |
|
| 1197 |
static assert(fun20022_3.mangleof == `_Z10fun20022_3N7ns2002211Enum20022_2E`); |
| 1198 |
static assert(fun20022_4.mangleof == `_ZN7ns2002210fun20022_4ENS_11Enum20022_2E`); |
| 1199 |
static assert(fun20022_5.mangleof == `_ZN7ns2002210fun20022_5ENS_11Enum20022_1E`); |
| 1200 |
static assert(fun20022_6.mangleof == `_ZN7ns2002210fun20022_6ENS_11Enum20022_2E`); |
| 1201 |
} |
| 1202 |
|
| 1203 |
// https://issues.dlang.org/show_bug.cgi?id=20094 |
| 1204 |
version (CppMangle_Itanium) |
| 1205 |
{ |
| 1206 |
extern(C++, "ns20094") |
| 1207 |
{ |
| 1208 |
struct xvector20094 (T) {} |
| 1209 |
alias V20094 = xvector20094!(ubyte); |
| 1210 |
} |
| 1211 |
|
| 1212 |
extern(C++) void test20094(xvector20094!(V20094)* v); |
| 1213 |
static assert(test20094.mangleof == `_Z9test20094PN7ns2009412xvector20094INS0_IhEEEE`); |
| 1214 |
} |
| 1215 |
|
| 1216 |
// https://issues.dlang.org/show_bug.cgi?id=20223 |
| 1217 |
version (CppMangle_Itanium) |
| 1218 |
{ |
| 1219 |
extern(C++) |
| 1220 |
{ |
| 1221 |
int test20223_1(T)(int function(const(T)* value)); |
| 1222 |
int test20223_2(T)(int function(ref const(T) value)); |
| 1223 |
|
| 1224 |
struct Struct20223_1 {} |
| 1225 |
struct Struct20223_2 {} |
| 1226 |
int test20223_3(ref const Struct20223_1, Struct20223_2*, Struct20223_2*); |
| 1227 |
int test20223_4(ref const Struct20223_1, const ref Struct20223_2, Struct20223_2*); |
| 1228 |
|
| 1229 |
struct Struct20223_3 (T) {} |
| 1230 |
void test20223_5(ref Struct20223_1, ref Struct20223_3!(const(char)*), |
| 1231 |
ref Struct20223_3!(const(char)*)); |
| 1232 |
} |
| 1233 |
static assert(test20223_1!int.mangleof == `_Z11test20223_1IiEiPFiPKT_E`); |
| 1234 |
static assert(test20223_2!int.mangleof == `_Z11test20223_2IiEiPFiRKT_E`); |
| 1235 |
static assert(test20223_1!(int*).mangleof == `_Z11test20223_1IPiEiPFiPKT_E`); |
| 1236 |
static assert(test20223_2!(int*).mangleof == `_Z11test20223_2IPiEiPFiRKT_E`); |
| 1237 |
static assert(test20223_3.mangleof == `_Z11test20223_3RK13Struct20223_1P13Struct20223_2S3_`); |
| 1238 |
static assert(test20223_4.mangleof == `_Z11test20223_4RK13Struct20223_1RK13Struct20223_2PS2_`); |
| 1239 |
static assert(test20223_5.mangleof == `_Z11test20223_5R13Struct20223_1R13Struct20223_3IPKcES5_`); |
| 1240 |
} |
| 1241 |
|
| 1242 |
// https://issues.dlang.org/show_bug.cgi?id=20224 |
| 1243 |
version (CppMangle_Itanium) |
| 1244 |
{ |
| 1245 |
extern(C++) public int test20224_1(T)(set20224!T set); // ok |
| 1246 |
extern(C++) public int test20224_2(T)(ref set20224!T set); // segfault |
| 1247 |
|
| 1248 |
extern(C++) struct set20224 (T) |
| 1249 |
{ |
| 1250 |
void test () |
| 1251 |
{ |
| 1252 |
test20224_1!T(this); |
| 1253 |
test20224_2!T(this); // segfaults |
| 1254 |
} |
| 1255 |
} |
| 1256 |
|
| 1257 |
extern(D) void func20224 () |
| 1258 |
{ |
| 1259 |
set20224!int x; |
| 1260 |
} |
| 1261 |
} |
| 1262 |
|
| 1263 |
/**************************************/ |
| 1264 |
|
| 1265 |
version (CppMangle_Itanium) |
| 1266 |
{ |
| 1267 |
extern (C++) struct Loc2 {}; |
| 1268 |
extern (C++) class FuncDeclaration |
| 1269 |
{ |
| 1270 |
static FuncDeclaration create(ref const Loc2, ref const Loc2); |
| 1271 |
}; |
| 1272 |
extern (C++) FuncDeclaration FuncDeclaration_create(ref const Loc2, ref const Loc2); |
| 1273 |
|
| 1274 |
static assert(FuncDeclaration_create.mangleof == `_Z22FuncDeclaration_createRK4Loc2S1_`); |
| 1275 |
static assert(FuncDeclaration.create.mangleof == `_ZN15FuncDeclaration6createERK4Loc2S2_`); |
| 1276 |
} |
| 1277 |
|
| 1278 |
enum Enum19542 = func19542!(int).mangleof; |
| 1279 |
|
| 1280 |
extern(C++, `bar`) |
| 1281 |
{ |
| 1282 |
void func19542(T)(); |
| 1283 |
} |
| 1284 |
|
| 1285 |
// https://issues.dlang.org/show_bug.cgi?id=20700 |
| 1286 |
// Only testing on WIn64 because the mangling includes 'E', |
| 1287 |
// and the bug can be tested on either platform |
| 1288 |
version (CppMangle_MSVC) version (Win64) extern(C++) |
| 1289 |
{ |
| 1290 |
void test20700_1(Struct20700); |
| 1291 |
extern(C++, class) struct Struct20700 {} |
| 1292 |
void test20700_2(Struct20700); |
| 1293 |
|
| 1294 |
// Note: Needs to be `V` (`class`), not `U` (`struct`) |
| 1295 |
static assert(test20700_1.mangleof == `?test20700_1@@YAXVStruct20700@@@Z`); |
| 1296 |
static assert(test20700_2.mangleof == `?test20700_2@@YAXVStruct20700@@@Z`); |
| 1297 |
|
| 1298 |
// Test that the scope is not "sticky" on the arguments |
| 1299 |
void test20700_3(TStruct20700_1!DefaultClass20700_1); |
| 1300 |
extern(C++, class) struct TStruct20700_1 (T1, T2 = DefaultStruct20700_1) {} |
| 1301 |
extern(C++, class) struct DefaultStruct20700_1 {} |
| 1302 |
extern(C++, struct) class DefaultClass20700_1 {} |
| 1303 |
static assert(test20700_3.mangleof == `?test20700_3@@YAXV?$TStruct20700_1@PEAUDefaultClass20700_1@@VDefaultStruct20700_1@@@@@Z`); |
| 1304 |
|
| 1305 |
// Each test needs to be independent symbol to trigger a new semantic pass |
| 1306 |
void test20700_4(TStruct20700_2!(DefaultClass20700_2, DefaultStruct20700_2)); |
| 1307 |
extern(C++, struct) class TStruct20700_2 (T1, T2 = DefaultClass20700_2) {} |
| 1308 |
extern(C++, class) struct DefaultStruct20700_2 {} |
| 1309 |
extern(C++, struct) class DefaultClass20700_2 {} |
| 1310 |
static assert(test20700_4.mangleof == `?test20700_4@@YAXPEAU?$TStruct20700_2@PEAUDefaultClass20700_2@@VDefaultStruct20700_2@@@@@Z`); |
| 1311 |
} |
| 1312 |
|
| 1313 |
/*****************************************/ |
| 1314 |
|
| 1315 |
alias noreturn = typeof(*null); |
| 1316 |
|
| 1317 |
extern (C++) |
| 1318 |
{ |
| 1319 |
alias fpcpp = noreturn function(); |
| 1320 |
int funccpp(fpcpp); |
| 1321 |
|
| 1322 |
version (CppMangle_Itanium) |
| 1323 |
static assert(funccpp.mangleof == "_Z7funccppPFvvE"); |
| 1324 |
|
| 1325 |
version (CppMangle_MSVC) |
| 1326 |
{ |
| 1327 |
version (Win32) |
| 1328 |
static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); |
| 1329 |
|
| 1330 |
version (Win64) |
| 1331 |
static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); |
| 1332 |
} |
| 1333 |
} |
| 1334 |
|
| 1335 |
/*****************************************/ |
| 1336 |
|
| 1337 |
extern(C++) enum _LIBNAME = "library"; |
| 1338 |
extern(C++) enum _DEBUG = _LIBNAME.length && 'd' == _LIBNAME[$-1]; |