Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/disable_new.d

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/disable_new.d(23): Error: cannot allocate `class C` with `new` because it is annotated with `@disable new()`
5 fail_compilation/disable_new.d(24): Error: cannot allocate `struct S` with `new` because it is annotated with `@disable new()`
6 ---
7 */
8
9 class C
10 {
11 // force user of a type to use an external allocation strategy
12 @disable new();
13 }
14
15 struct S
16 {
17 // force user of a type to use an external allocation strategy
18 @disable new();
19 }
20
21 void main()
22 {
23 auto c = new C();
24 auto s = new S();
25 }