]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/compilable/test11169.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / test11169.d
1 // REQUIRED_ARGS: -o-
2 /*
3 TEST_OUTPUT:
4 ---
5 1: false
6 2: true
7 3: true
8 ---
9 */
10
11 class A
12 {
13 abstract void foo();
14 }
15
16 template MixinAbstractBar() { abstract void bar(); }
17
18 class B1 : A
19 {
20 // Use pragma instead of static assert, in order to evaluate
21 // __traits during ClassDeclaration.semantic().
22 pragma(msg, "1: ", __traits(isAbstractClass, typeof(this)));
23 override void foo() {}
24 }
25
26 class B2 : A
27 {
28 pragma(msg, "2: ", __traits(isAbstractClass, typeof(this)));
29 override void foo() {}
30 abstract void bar();
31 }
32
33 class B3 : A
34 {
35 pragma(msg, "3: ", __traits(isAbstractClass, typeof(this)));
36 override void foo() {}
37 mixin MixinAbstractBar!();
38 }
39
40 void main()
41 {
42 static assert( __traits(compiles, { auto b = new B1(); }));
43 static assert(!__traits(compiles, { auto b = new B2(); }));
44 static assert(!__traits(compiles, { auto b = new B3(); }));
45 }
46
47 class B : A
48 {
49 // __traits(isAbstractClass) is not usable in static if condition.
50 static assert (!__traits(isAbstractClass, typeof(this)));
51
52 override void foo()
53 {
54 }
55 }
56
57 void main2()
58 {
59 B b = new B();
60 }