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