Debian Codegraph @

gcc/testsuite/gdc.test/compilable/testparse.d

raw
1 // PERMUTE_ARGS:
2 // REQUIRED_ARGS: -o-
3
4 /***************************************************/
5 // https://issues.dlang.org/show_bug.cgi?id=6719
6
7 static assert(__traits(compiles, mixin("(const(A))[0..0]")) == false);
8
9 /***************************************************/
10 // https://issues.dlang.org/show_bug.cgi?id=9232
11
12 struct Foo9232
13 {
14 void bar(T)() {}
15 void baz() {}
16 }
17
18 void test9232()
19 {
20 Foo9232 foo;
21 (foo).bar!int(); // OK <- Error: found '!' when expecting ';' following statement
22 ((foo)).bar!int(); // OK
23 foo.bar!int(); // OK
24 (foo).baz(); // OK
25 }
26
27 /***************************************************/
28 // https://issues.dlang.org/show_bug.cgi?id=9401
29
30 struct S9401a
31 {
32 ~this() nothrow pure @safe { }
33 }
34
35 struct S9401b
36 {
37 @safe ~this() pure nothrow { }
38 }
39
40 void test9401() nothrow pure @safe
41 {
42 S9401a s1;
43 S9401b s2;
44 }
45
46 /***************************************************/
47 // https://issues.dlang.org/show_bug.cgi?id=9649
48
49 class Outer9649
50 {
51 class Inner
52 {
53 }
54 }
55
56 void test9649()
57 {
58 Outer9649 outer9649;
59 (outer9649).new Inner();
60 }
61
62 /***************************************************/
63 // https://issues.dlang.org/show_bug.cgi?id=9679
64
65 void test9679(inout int = 0)
66 {
67 if ( auto n = 1) { static assert(is(typeof(n) == int)); }
68 if ( const n = 1) { static assert(is(typeof(n) == const int)); }
69 if ( immutable n = 1) { static assert(is(typeof(n) == immutable int)); }
70 if (shared n = 1) { static assert(is(typeof(n) == shared int)); }
71 if (shared const n = 1) { static assert(is(typeof(n) == shared const int)); }
72 if ( inout n = 1) { static assert(is(typeof(n) == inout int)); }
73 if (shared inout n = 1) { static assert(is(typeof(n) == shared inout int)); }
74
75 if ( const int n = 1) { static assert(is(typeof(n) == const int)); }
76 if ( immutable int n = 1) { static assert(is(typeof(n) == immutable int)); }
77 if (shared int n = 1) { static assert(is(typeof(n) == shared int)); }
78 if (shared const int n = 1) { static assert(is(typeof(n) == shared const int)); }
79 if ( inout int n = 1) { static assert(is(typeof(n) == inout int)); }
80 if (shared inout int n = 1) { static assert(is(typeof(n) == shared inout int)); }
81
82 if ( const(int) n = 1) { static assert(is(typeof(n) == const int)); }
83 if ( immutable(int) n = 1) { static assert(is(typeof(n) == immutable int)); }
84 if (shared (int) n = 1) { static assert(is(typeof(n) == shared int)); }
85 if (shared const(int) n = 1) { static assert(is(typeof(n) == shared const int)); }
86 if ( inout(int) n = 1) { static assert(is(typeof(n) == inout int)); }
87 if (shared inout(int) n = 1) { static assert(is(typeof(n) == shared inout int)); }
88
89 if (immutable(int)[] n = [1]) { static assert(is(typeof(n) == immutable(int)[])); }
90 }
91
92 /***************************************************/
93 // https://issues.dlang.org/show_bug.cgi?id=9901
94
95 template isGood9901(T)
96 {
97 enum isGood9901 = true;
98 }
99 void test9901()
100 {
101 string foo(R)(R data) if (isGood9901!R)
102 {
103 return "";
104 }
105 foo(1);
106 }
107
108 /***************************************************/
109 // https://issues.dlang.org/show_bug.cgi?id=10199
110
111 void test10199()
112 {
113 goto label;
114 label:
115 }
116
117 /***************************************************/
118 // https://issues.dlang.org/show_bug.cgi?id=12460
119
120 void f12460(T)()
121 {
122 static if (is(T == int))
123 {
124 goto end;
125 }
126 end:
127 }
128
129 void test12460()
130 {
131 f12460!int();
132 }
133
134 /***************************************************/
135 // https://issues.dlang.org/show_bug.cgi?id=11689
136
137 void test11689()
138 {
139 deprecated void foo() {}
140 }
141
142 /***************************************************/
143 // https://issues.dlang.org/show_bug.cgi?id=11751
144
145 static assert(is(float == typeof(0x0.1p1F)));
146
147 /***************************************************/
148 // https://issues.dlang.org/show_bug.cgi?id=11957
149
150 extern(C++) class C11957
151 {
152 void x() {}
153 }
154
155 void test11957()
156 {
157 extern(C++) class D : C11957
158 {
159 override void x() {}
160 }
161 }
162
163 /***************************************************/
164 // https://issues.dlang.org/show_bug.cgi?id=13049
165
166 enum mangle13049(T) = T.mangleof;
167 alias FP13049 = void function(scope int); // OK
168 static assert(mangle13049!FP13049 == mangle13049!(void function(scope int))); // OK <- NG
169
170 /***************************************************/
171 // was not covered until the **12th of March 2019**
172 void testIfConditionWithSTCandType()
173 {
174 auto call(){return 0;}
175 if (const size_t i = call()) {}
176 }
177
178 /***************************************************/
179 // https://issues.dlang.org/show_bug.cgi?id=20791
180 extern(C++, "foo", )
181 struct S {}
182
183 /***************************************************/
184 // https://issues.dlang.org/show_bug.cgi?id=22019
185 void test22019()
186 {
187 final switch (1)
188 {
189 case 1,:
190 case 2,3,:
191 break;
192 }
193 }
194
195 /***************************************************/
196 // https://issues.dlang.org/show_bug.cgi?id=23205
197
198 void test23205()
199 {
200 mixin template tpl() { int x; }
201 mixin tpl!();
202 x = 123;
203 }