Debian Codegraph @

gcc/testsuite/gdc.test/runnable/testclass.d

raw
1 /*
2 RUN_OUTPUT:
3 ---
4 Success
5 ---
6 */
7 extern(C) int printf(const char*, ...);
8
9 /******************************************/
10 // https://issues.dlang.org/show_bug.cgi?id=12078
11
12 class B12078(T)
13 {
14 static assert(is(T : B12078!T), "not related");
15 }
16 class D12078 : B12078!D12078
17 {
18 }
19
20 interface X12078(T)
21 {
22 static assert(is(T : X12078!T), "not related");
23 }
24 interface Y12078 : X12078!Y12078
25 {
26 }
27
28 void test12078()
29 {
30 static assert(is(D12078 : B12078!D12078));
31 static assert(is(Y12078 : X12078!Y12078));
32 }
33
34 /******************************************/
35 // https://issues.dlang.org/show_bug.cgi?id=12143
36
37 class Node12143
38 {
39 alias typeof(true ? Node12143.init : Class12143.init) V;
40 static assert(is(V == Node12143));
41 }
42
43 class Type12143 : Node12143 {}
44
45 class Class12143 : Type12143 {}
46
47 /***************************************************/
48 // https://issues.dlang.org/show_bug.cgi?id=13353
49
50 interface Base13353(T)
51 {
52 static assert(is(T : Base13353!T));
53 }
54
55 interface Derived13353 : Base13353!Derived13353
56 {
57 void func();
58 }
59
60 class Concrete13353 : Derived13353
61 {
62 void func() {}
63 }
64
65 /***************************************************/
66 // https://issues.dlang.org/show_bug.cgi?id=15733
67
68 class CStmt15733 : CNode15733 {}
69 class CDecl15733 : CStmt15733 {}
70 class CNode15733 { mixin CMix!CDecl15733; }
71 template CMix(T){ mixin("static " ~ T.stringof ~ " x;"); }
72
73 interface IStmt15733 : INode15733 {}
74 interface IDecl15733 : IStmt15733 {}
75 interface INode15733 { mixin IMix!IDecl15733; }
76 template IMix(T){ mixin("static " ~ T.stringof ~ " x;"); }
77
78 /***************************************************/
79
80 // https://issues.dlang.org/show_bug.zip?id=20716
81
82 extern(C++):
83
84 struct S20716
85 {
86 void* s;
87 ~this() {}
88 // or this(this) {}
89 }
90
91 interface I20716
92 {
93 S20716 x();
94 }
95
96 final class C20716 : I20716
97 {
98 int l = 3;
99
100 S20716 x()
101 {
102 //printf("this = %p, %p\n", this, &this.l);
103 assert(l == 3); //fails
104 return S20716.init;
105 }
106 }
107
108 extern(D):
109
110 void test20716()
111 {
112 auto s = new C20716().x;
113 auto t = new C20716().I20716.x;
114 }
115
116 /***************************************************/
117
118 int main()
119 {
120 test20716();
121
122 printf("Success\n");
123 return 0;
124 }