]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/fail_compilation/fail94.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail94.d
CommitLineData
7da827c9
IB
1/*
2TEST_OUTPUT:
3---
4fail_compilation/fail94.d(28): Error: cannot implicitly override base class method `fail94.A.clone` with `fail94.B.clone`; add `override` attribute
5---
6*/
b4c522fa
IB
7interface I
8{
9 int foo();
10}
11
12class IA : I
13{
14 int foo() { return 1; }
15}
16
17class A
18{
19 I i;
20
21 I clone() { return i; }
22}
23
24class B : A
25{
26 IA ia;
27
28 IA clone()
29 out (result)
30 {
31 printf("B.clone()\n");
32 }
5fee5ec3 33 do { return ia; }
b4c522fa
IB
34}
35
36void main()
37{
38 IA ia = new IA;
39 assert(ia.foo() == 1);
40
41 I i = ia;
42 assert(i.foo() == 1);
43
44 A a = new A;
45 a.i = i;
46 assert(a.clone().foo() == 1);
47
48 B b = new B;
49 b.ia = ia;
50 assert(b.clone().foo() == 1);
51
52 a = b;
53 assert(a.clone().foo() == 1);
54
55 bar(&b.clone);
56}
57
58
59void bar(IA delegate() dg)
60{
61}