Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -5130,6 +5130,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor

override void visit(DeleteExp exp)
{
// @@@DEPRECATED_2019-02@@@
// 1. Deprecation for 1 year
// 2. Error for 1 year
// 3. Removal of keyword, "delete" can be used for other identities
if (!exp.isRAII)
deprecation(exp.loc, "The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.");

if (Expression ex = unaSemantic(exp, sc))
{
result = ex;
Expand Down
5 changes: 0 additions & 5 deletions src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -7758,11 +7758,6 @@ final class Parser(AST) : Lexer
case TOK.delete_:
nextToken();
e = parseUnaryExp();
// @@@DEPRECATED_2019-02@@@
// 1. Deprecation for 1 year
// 2. Error for 1 year
// 3. Removal, "delete" can be used for other identities
deprecation("The `delete` keyword has been deprecated. Use `object.destroy()` instead.");
e = new AST.DeleteExp(loc, e, false);
break;

Expand Down
42 changes: 18 additions & 24 deletions test/compilable/vgc1.d
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// REQUIRED_ARGS: -vgc -o-
// PERMUTE_ARGS:

/*
TEST_OUTPUT:
---
compilable/vgc1.d(93): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
compilable/vgc1.d(94): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
compilable/vgc1.d(95): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
---
*/

/***************** NewExp *******************/

struct S1 { }
Expand All @@ -21,13 +12,13 @@ struct S5 { @nogc new(size_t); }
/*
TEST_OUTPUT:
---
compilable/vgc1.d(36): vgc: `new` causes a GC allocation
compilable/vgc1.d(27): vgc: `new` causes a GC allocation
compilable/vgc1.d(29): vgc: `new` causes a GC allocation
compilable/vgc1.d(30): vgc: `new` causes a GC allocation
compilable/vgc1.d(32): vgc: `new` causes a GC allocation
compilable/vgc1.d(33): vgc: `new` causes a GC allocation
compilable/vgc1.d(34): vgc: `new` causes a GC allocation
compilable/vgc1.d(38): vgc: `new` causes a GC allocation
compilable/vgc1.d(39): vgc: `new` causes a GC allocation
compilable/vgc1.d(41): vgc: `new` causes a GC allocation
compilable/vgc1.d(42): vgc: `new` causes a GC allocation
compilable/vgc1.d(43): vgc: `new` causes a GC allocation
compilable/vgc1.d(47): vgc: `new` causes a GC allocation
---
*/

Expand All @@ -50,12 +41,12 @@ void testNew()
/*
TEST_OUTPUT:
---
compilable/vgc1.d(64): vgc: `new` causes a GC allocation
compilable/vgc1.d(66): vgc: `new` causes a GC allocation
compilable/vgc1.d(67): vgc: `new` causes a GC allocation
compilable/vgc1.d(69): vgc: `new` causes a GC allocation
compilable/vgc1.d(70): vgc: `new` causes a GC allocation
compilable/vgc1.d(71): vgc: `new` causes a GC allocation
compilable/vgc1.d(55): vgc: `new` causes a GC allocation
compilable/vgc1.d(57): vgc: `new` causes a GC allocation
compilable/vgc1.d(58): vgc: `new` causes a GC allocation
compilable/vgc1.d(60): vgc: `new` causes a GC allocation
compilable/vgc1.d(61): vgc: `new` causes a GC allocation
compilable/vgc1.d(62): vgc: `new` causes a GC allocation
---
*/

Expand Down Expand Up @@ -83,9 +74,12 @@ void testNewScope()
/*
TEST_OUTPUT:
---
compilable/vgc1.d(93): vgc: `delete` requires the GC
compilable/vgc1.d(94): vgc: `delete` requires the GC
compilable/vgc1.d(95): vgc: `delete` requires the GC
compilable/vgc1.d(87): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
compilable/vgc1.d(87): vgc: `delete` requires the GC
compilable/vgc1.d(88): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
compilable/vgc1.d(88): vgc: `delete` requires the GC
compilable/vgc1.d(89): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
compilable/vgc1.d(89): vgc: `delete` requires the GC
---
*/
void testDelete(int* p, Object o, S1* s)
Expand Down
148 changes: 71 additions & 77 deletions test/fail_compilation/fail14486.d

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/fail_compilation/fail2361.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail2361.d(14): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/fail2361.d(14): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/fail2361.d(14): Error: cannot modify `immutable` expression `c`
---
*/
Expand Down
6 changes: 3 additions & 3 deletions test/fail_compilation/fail_arrayop2.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// REQUIRED_ARGS: -o-


/*
TEST_OUTPUT:
---
fail_compilation/fail_arrayop2.d(281): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/fail_arrayop2.d(13): Error: array operation `[1, 2, 3] - [1, 2, 3]` without destination memory not allowed
fail_compilation/fail_arrayop2.d(16): Error: invalid array operation `"a" - "b"` (possible missing [])
---
Expand Down Expand Up @@ -198,9 +198,9 @@ void test14895()
/*
TEST_OUTPUT:
---
fail_compilation/fail_arrayop2.d(246): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(247): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(248): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(249): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(253): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(256): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(265): Error: array operation `[1] * 6` without destination memory not allowed
Expand All @@ -209,6 +209,7 @@ fail_compilation/fail_arrayop2.d(269): Error: array operation `"abc"[] + '\x01'`
fail_compilation/fail_arrayop2.d(272): Error: array operation `[1] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(275): Error: `([1] * 6)[0..2]` is not an lvalue
fail_compilation/fail_arrayop2.d(278): Error: can only `*` a pointer, not a `int[]`
fail_compilation/fail_arrayop2.d(281): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/fail_arrayop2.d(281): Error: `[1] * 6` is not an lvalue
fail_compilation/fail_arrayop2.d(284): Error: array operation `da[] * 6` without destination memory not allowed
fail_compilation/fail_arrayop2.d(287): Error: array operation `da[] * 6` without destination memory not allowed
Expand Down Expand Up @@ -248,7 +249,6 @@ void test15407exp()
[1] * 6]; } // AssocArrayLiteralExp

//TupleExp

// StructLiteralExp.elements <- preFunctionParameters in CallExp
{ auto r = S([1] * 6); }

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/faildeleteaa.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/faildeleteaa.d(12): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/faildeleteaa.d(12): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/faildeleteaa.d(12): Error: cannot delete type `int`
---
*/
Expand Down
46 changes: 20 additions & 26 deletions test/fail_compilation/nogc1.d
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// REQUIRED_ARGS: -o-
// PERMUTE_ARGS:

/*
TEST_OUTPUT:
---
fail_compilation/nogc1.d(91): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/nogc1.d(92): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/nogc1.d(93): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
---
*/

/***************** NewExp *******************/

struct S1 { }
Expand All @@ -21,14 +12,14 @@ struct S5 { @nogc new(size_t); }
/*
TEST_OUTPUT:
---
fail_compilation/nogc1.d(36): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(27): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(29): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(30): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(32): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(33): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc constructor `nogc1.S2.this`
fail_compilation/nogc1.d(34): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(35): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc allocator `nogc1.S4.new`
fail_compilation/nogc1.d(38): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(39): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(41): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(42): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc constructor `nogc1.S2.this`
fail_compilation/nogc1.d(43): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
fail_compilation/nogc1.d(44): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc allocator `nogc1.S4.new`
fail_compilation/nogc1.d(47): Error: cannot use `new` in `@nogc` function `nogc1.testNew`
---
*/
@nogc void testNew()
Expand All @@ -50,13 +41,13 @@ fail_compilation/nogc1.d(47): Error: cannot use `new` in `@nogc` function `nogc1
/*
TEST_OUTPUT:
---
fail_compilation/nogc1.d(64): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(66): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(67): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(69): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(70): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc constructor `nogc1.S2.this`
fail_compilation/nogc1.d(71): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(72): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc allocator `nogc1.S4.new`
fail_compilation/nogc1.d(55): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(57): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(58): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(60): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(61): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc constructor `nogc1.S2.this`
fail_compilation/nogc1.d(62): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope`
fail_compilation/nogc1.d(63): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc allocator `nogc1.S4.new`
---
*/
@nogc void testNewScope()
Expand All @@ -81,9 +72,12 @@ fail_compilation/nogc1.d(72): Error: `@nogc` function `nogc1.testNewScope` canno
/*
TEST_OUTPUT:
---
fail_compilation/nogc1.d(91): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
fail_compilation/nogc1.d(92): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
fail_compilation/nogc1.d(93): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
fail_compilation/nogc1.d(85): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/nogc1.d(85): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
fail_compilation/nogc1.d(86): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/nogc1.d(86): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
fail_compilation/nogc1.d(87): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/nogc1.d(87): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete`
---
*/
@nogc void testDelete(int* p, Object o, S1* s)
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/test16195.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* TEST_OUTPUT:
---
fail_compilation/test16195.d(14): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` instead.
fail_compilation/test16195.d(14): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead.
fail_compilation/test16195.d(14): Error: `delete p` is not `@safe` but is used in `@safe` function `test`
---
*/
Expand Down