Skip to content

Commit 923a7ac

Browse files
committed
fix Issue 18530 - src/rt/tracegc.d(43): Deprecation: The delete keyword has been deprecated
defer deprecation message into semantic stage so it can still be versioned out
1 parent 36c92d6 commit 923a7ac

6 files changed

Lines changed: 119 additions & 135 deletions

File tree

src/dmd/expressionsem.d

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5130,6 +5130,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
51305130

51315131
override void visit(DeleteExp exp)
51325132
{
5133+
// @@@DEPRECATED_2019-02@@@
5134+
// 1. Deprecation for 1 year
5135+
// 2. Error for 1 year
5136+
// 3. Removal, "delete" can be used for other identities
5137+
if (!exp.isRAII)
5138+
deprecation(exp.loc, "The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.");
5139+
51335140
if (Expression ex = unaSemantic(exp, sc))
51345141
{
51355142
result = ex;

src/dmd/parse.d

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7758,11 +7758,6 @@ final class Parser(AST) : Lexer
77587758
case TOK.delete_:
77597759
nextToken();
77607760
e = parseUnaryExp();
7761-
// @@@DEPRECATED_2019-02@@@
7762-
// 1. Deprecation for 1 year
7763-
// 2. Error for 1 year
7764-
// 3. Removal, "delete" can be used for other identities
7765-
deprecation("The `delete` keyword has been deprecated. Use `object.destroy()` instead.");
77667761
e = new AST.DeleteExp(loc, e, false);
77677762
break;
77687763

test/compilable/vgc1.d

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
// REQUIRED_ARGS: -vgc -o-
22
// PERMUTE_ARGS:
33

4-
/*
5-
TEST_OUTPUT:
6-
---
7-
compilable/vgc1.d(93): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
8-
compilable/vgc1.d(94): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
9-
compilable/vgc1.d(95): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
10-
---
11-
*/
12-
134
/***************** NewExp *******************/
145

156
struct S1 { }
@@ -21,13 +12,13 @@ struct S5 { @nogc new(size_t); }
2112
/*
2213
TEST_OUTPUT:
2314
---
24-
compilable/vgc1.d(36): vgc: `new` causes a GC allocation
15+
compilable/vgc1.d(27): vgc: `new` causes a GC allocation
16+
compilable/vgc1.d(29): vgc: `new` causes a GC allocation
17+
compilable/vgc1.d(30): vgc: `new` causes a GC allocation
18+
compilable/vgc1.d(32): vgc: `new` causes a GC allocation
19+
compilable/vgc1.d(33): vgc: `new` causes a GC allocation
20+
compilable/vgc1.d(34): vgc: `new` causes a GC allocation
2521
compilable/vgc1.d(38): vgc: `new` causes a GC allocation
26-
compilable/vgc1.d(39): vgc: `new` causes a GC allocation
27-
compilable/vgc1.d(41): vgc: `new` causes a GC allocation
28-
compilable/vgc1.d(42): vgc: `new` causes a GC allocation
29-
compilable/vgc1.d(43): vgc: `new` causes a GC allocation
30-
compilable/vgc1.d(47): vgc: `new` causes a GC allocation
3122
---
3223
*/
3324

@@ -50,12 +41,12 @@ void testNew()
5041
/*
5142
TEST_OUTPUT:
5243
---
53-
compilable/vgc1.d(64): vgc: `new` causes a GC allocation
54-
compilable/vgc1.d(66): vgc: `new` causes a GC allocation
55-
compilable/vgc1.d(67): vgc: `new` causes a GC allocation
56-
compilable/vgc1.d(69): vgc: `new` causes a GC allocation
57-
compilable/vgc1.d(70): vgc: `new` causes a GC allocation
58-
compilable/vgc1.d(71): vgc: `new` causes a GC allocation
44+
compilable/vgc1.d(55): vgc: `new` causes a GC allocation
45+
compilable/vgc1.d(57): vgc: `new` causes a GC allocation
46+
compilable/vgc1.d(58): vgc: `new` causes a GC allocation
47+
compilable/vgc1.d(60): vgc: `new` causes a GC allocation
48+
compilable/vgc1.d(61): vgc: `new` causes a GC allocation
49+
compilable/vgc1.d(62): vgc: `new` causes a GC allocation
5950
---
6051
*/
6152

@@ -83,9 +74,12 @@ void testNewScope()
8374
/*
8475
TEST_OUTPUT:
8576
---
86-
compilable/vgc1.d(93): vgc: `delete` requires the GC
87-
compilable/vgc1.d(94): vgc: `delete` requires the GC
88-
compilable/vgc1.d(95): vgc: `delete` requires the GC
77+
compilable/vgc1.d(87): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
78+
compilable/vgc1.d(87): vgc: `delete` requires the GC
79+
compilable/vgc1.d(88): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
80+
compilable/vgc1.d(88): vgc: `delete` requires the GC
81+
compilable/vgc1.d(89): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
82+
compilable/vgc1.d(89): vgc: `delete` requires the GC
8983
---
9084
*/
9185
void testDelete(int* p, Object o, S1* s)

0 commit comments

Comments
 (0)