1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*
https://issues.dlang.org/show_bug.cgi?id=21693
RUN_OUTPUT:
---
CppA:
1: CppA.~this
CppB:
2: CppB.~this
2: CppA.~this
CppC:
3: CppC.~this
3: CppB.~this
3: CppA.~this
CppC:
4: CppC.~this
4: CppB.~this
4: CppA.~this
CppNoDestruct:
DA:
1: DA.~this
DB:
2: DB.~this
2: DA.~this
DC:
3: DC.~this
3: DB.~this
3: DA.~this
DC:
4: DC.~this
4: DB.~this
4: DA.~this
---
*/
extern (C) int printf(scope const char*, ...);
extern (C++) class CppA
{
int num;
this(int num) scope
{
this.num = num;
}
~this() scope
{
printf("%d: CppA.~this\n", num);
}
}
extern (C++) class CppB : CppA
{
this(int num) scope
{
super(num);
}
~this() scope
{
printf("%d: CppB.~this\n", num);
}
}
extern (C++) class CppC : CppB
{
this(int num) scope
{
super(num);
}
~this() scope
{
printf("%d: CppC.~this\n", num);
}
}
extern (D) class DA
{
int num;
this(int num) scope
{
this.num = num;
}
~this() scope
{
printf("%d: DA.~this\n", num);
}
}
extern (D) class DB : DA
{
this(int num) scope
{
super(num);
}
~this() scope
{
printf("%d: DB.~this\n", num);
}
}
extern (D) class DC : DB
{
this(int num) scope
{
super(num);
}
~this() scope
{
printf("%d: DC.~this\n", num);
}
}
extern (C++) class CppNoDestruct
{
int num;
this(int num) scope
{
this.num = num;
}
}
void main()
{
printf("CppA:\n"); { scope a = new CppA(1); }
printf("CppB:\n"); { scope CppA b = new CppB(2); }
printf("CppC:\n"); { scope CppA c = new CppC(3); }
printf("CppC:\n"); { scope CppB c2 = new CppC(4); }
printf("CppNoDestruct:\n");
{
scope const nd = new CppNoDestruct(1);
}
printf("DA:\n"); { scope a = new DA(1); }
printf("DB:\n"); { scope DA b = new DB(2); }
printf("DC:\n"); { scope DA c = new DC(3); }
printf("DC:\n"); { scope DB c2 = new DC(4); }
}
|