Debian Codegraph @

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

raw
1 /*
2 PERMUTE_ARGS:
3 RUN_OUTPUT:
4 ---
5 shared static this()
6 Foo static ctor
7 static ctor
8 Bar static ctor
9 Bar static dtor
10 static dtor
11 Foo static dtor
12 shared static this()
13 ---
14 */
15
16 private import core.stdc.stdio;
17
18 class Foo
19 {
20 static this() {printf("Foo static ctor\n");}
21 static ~this() {printf("Foo static dtor\n");}
22 }
23
24 static this() {printf("static ctor\n");}
25 static ~this() {printf("static dtor\n");}
26
27 shared static this()
28 {
29 printf("shared static this()\n");
30 }
31
32 shared static ~this()
33 {
34 printf("shared static this()\n");
35 }
36
37 class Bar
38 {
39 static this() {printf("Bar static ctor\n");}
40 static ~this() {printf("Bar static dtor\n");}
41 }
42
43 /***********************************************/
44 // https://issues.dlang.org/show_bug.cgi?id=6677
45
46 int global6677;
47
48 static this() nothrow pure @safe
49 {
50 int* p;
51 static assert(!__traits(compiles, ++p));
52 static assert(!__traits(compiles, ++global6677));
53 auto throwit = { throw new Exception("sup"); };
54 static assert(!__traits(compiles, throwit() ));
55 }
56
57 shared static this() nothrow pure @safe
58 {
59 int* p;
60 static assert(!__traits(compiles, ++p));
61 static assert(!__traits(compiles, ++global6677));
62 }
63
64 /***********************************************/
65 // https://issues.dlang.org/show_bug.cgi?id=7533
66 struct Foo7533(int n)
67 {
68 pure static this() { }
69 }
70
71 alias Foo7533!5 Bar7533;
72
73 /***********************************************/
74
75 int main()
76 {
77 return 0;
78 }