]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/compilable/vgc1.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / vgc1.d
1 // REQUIRED_ARGS: -vgc -o-
2 // PERMUTE_ARGS:
3
4 /***************** NewExp *******************/
5
6 struct S1 { }
7 struct S2 { this(int); }
8 struct S3 { this(int) @nogc; }
9 struct S4 { new(size_t); }
10 struct S5 { @nogc new(size_t); }
11
12 /*
13 TEST_OUTPUT:
14 ---
15 compilable/vgc1.d(27): vgc: 'new' causes GC allocation
16 compilable/vgc1.d(29): vgc: 'new' causes GC allocation
17 compilable/vgc1.d(30): vgc: 'new' causes GC allocation
18 compilable/vgc1.d(32): vgc: 'new' causes GC allocation
19 compilable/vgc1.d(33): vgc: 'new' causes GC allocation
20 compilable/vgc1.d(34): vgc: 'new' causes GC allocation
21 compilable/vgc1.d(38): vgc: 'new' causes GC allocation
22 ---
23 */
24
25 void testNew()
26 {
27 int* p1 = new int;
28
29 int[] a1 = new int[3];
30 int[][] a2 = new int[][](2, 3);
31
32 S1* ps1 = new S1();
33 S2* ps2 = new S2(1);
34 S3* ps3 = new S3(1);
35 S4* ps4 = new S4; // no error
36 S5* ps5 = new S5; // no error
37
38 Object o1 = new Object();
39 }
40
41 /*
42 TEST_OUTPUT:
43 ---
44 compilable/vgc1.d(55): vgc: 'new' causes GC allocation
45 compilable/vgc1.d(57): vgc: 'new' causes GC allocation
46 compilable/vgc1.d(58): vgc: 'new' causes GC allocation
47 compilable/vgc1.d(60): vgc: 'new' causes GC allocation
48 compilable/vgc1.d(61): vgc: 'new' causes GC allocation
49 compilable/vgc1.d(62): vgc: 'new' causes GC allocation
50 ---
51 */
52
53 void testNewScope()
54 {
55 scope int* p1 = new int;
56
57 scope int[] a1 = new int[3];
58 scope int[][] a2 = new int[][](2, 3);
59
60 scope S1* ps1 = new S1();
61 scope S2* ps2 = new S2(1);
62 scope S3* ps3 = new S3(1);
63 scope S4* ps4 = new S4; // no error
64 scope S5* ps5 = new S5; // no error
65
66 scope Object o1 = new Object(); // no error
67 scope o2 = new Object(); // no error
68 scope Object o3;
69 o3 = o2; // no error
70 }
71
72 /***************** DeleteExp *******************/
73
74 /*
75 TEST_OUTPUT:
76 ---
77 compilable/vgc1.d(84): vgc: 'delete' requires GC
78 compilable/vgc1.d(85): vgc: 'delete' requires GC
79 compilable/vgc1.d(86): vgc: 'delete' requires GC
80 ---
81 */
82 void testDelete(int* p, Object o, S1* s)
83 {
84 delete p;
85 delete o;
86 delete s;
87 }