From fbad9d843e93dccaf3d760ca55f556d1824e6e9f Mon Sep 17 00:00:00 2001 From: JinShil Date: Tue, 14 May 2019 12:57:11 +0900 Subject: [PATCH] Advance deprecation of class allocators and deallocators: Removal --- changelog/remove_alloc_dealloc.dd | 7 ++ src/dmd/dsymbolsem.d | 17 +-- test/compilable/extra-files/header1.d | 3 - test/compilable/extra-files/header1.di | 2 - test/compilable/extra-files/header1i.di | 7 -- test/compilable/vgc1.d | 52 +++----- test/fail_compilation/diag_class_alloc.d | 23 ++++ test/fail_compilation/fail14249.d | 30 ++--- test/fail_compilation/fail14407.d | 51 -------- test/fail_compilation/fail14486.d | 154 +++++------------------ test/fail_compilation/fail7848.d | 49 ++------ test/fail_compilation/failmemalloc.d | 14 --- test/fail_compilation/imports/a14407.d | 19 --- test/fail_compilation/nogc1.d | 54 +++----- test/runnable/newdel.d | 63 +--------- test/runnable/sdtor.d | 19 +-- test/runnable/test20.d | 9 +- test/runnable/test23.d | 70 +---------- test/runnable/testdstress.d | 11 +- test/runnable/xtest46.d | 17 +-- 20 files changed, 144 insertions(+), 527 deletions(-) create mode 100644 changelog/remove_alloc_dealloc.dd create mode 100644 test/fail_compilation/diag_class_alloc.d delete mode 100644 test/fail_compilation/fail14407.d delete mode 100644 test/fail_compilation/failmemalloc.d delete mode 100644 test/fail_compilation/imports/a14407.d diff --git a/changelog/remove_alloc_dealloc.dd b/changelog/remove_alloc_dealloc.dd new file mode 100644 index 000000000000..1c01054c6d0e --- /dev/null +++ b/changelog/remove_alloc_dealloc.dd @@ -0,0 +1,7 @@ +Class allocators and deallocators are now obsolete + +Starting with this release any use of $(LINK2 https://dlang.org/spec/class.html#allocators, class allocators) +or $(LINK2 https://dlang.org/spec/class.html#deallocators, deallocators) will result in a compilation error. + +See the $(LINK2 https://dlang.org/deprecate.html#Class%20allocators%20and%20deallocators, deprecated features page) +for more information. diff --git a/src/dmd/dsymbolsem.d b/src/dmd/dsymbolsem.d index ff5406ba6377..e91630869319 100644 --- a/src/dmd/dsymbolsem.d +++ b/src/dmd/dsymbolsem.d @@ -4315,11 +4315,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor //printf("NewDeclaration::semantic()\n"); // `@disable new();` should not be deprecated - if (!nd.isDisabled() && !nd.isDeprecated()) + if (!nd.isDisabled()) { - // @@@DEPRECATED_2.084@@@ - // Should be changed to an error in 2.084 - deprecation(nd.loc, "class allocators have been deprecated, consider moving the allocation strategy outside of the class"); + // @@@DEPRECATED_2.091@@@ + // Made an error in 2.087. + // Should be removed in 2.091 + error(nd.loc, "class allocators are obsolete, consider moving the allocation strategy outside of the class"); } if (nd.semanticRun >= PASS.semanticdone) @@ -4369,10 +4370,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { //printf("DeleteDeclaration::semantic()\n"); - // @@@DEPRECATED_2.084@@@ - // Should be changed to an error in 2.084 - if (!deld.isDeprecated()) - deprecation(deld.loc, "class deallocators have been deprecated, consider moving the deallocation strategy outside of the class"); + // @@@DEPRECATED_2.091@@@ + // Made an error in 2.087. + // Should be removed in 2.091 + error(deld.loc, "class deallocators are obsolete, consider moving the deallocation strategy outside of the class"); if (deld.semanticRun >= PASS.semanticdone) return; diff --git a/test/compilable/extra-files/header1.d b/test/compilable/extra-files/header1.d index 9a2665a477ef..9eee6fe0158f 100644 --- a/test/compilable/extra-files/header1.d +++ b/test/compilable/extra-files/header1.d @@ -271,9 +271,6 @@ class Test pure nothrow @safe @nogc unittest {} pure nothrow @safe @nogc invariant {} pure nothrow @safe @nogc invariant (true); - - pure nothrow @safe @nogc new (size_t sz) { return null; } - pure nothrow @safe @nogc delete (void* p) { } } template templ( T ) diff --git a/test/compilable/extra-files/header1.di b/test/compilable/extra-files/header1.di index 46d6d925a276..d5ccaf41e1ac 100644 --- a/test/compilable/extra-files/header1.di +++ b/test/compilable/extra-files/header1.di @@ -250,8 +250,6 @@ class Test alias getHUShort = A!ushort; alias getHReal = A!real; alias void F(); - nothrow pure @nogc @safe new(size_t sz); - nothrow pure @nogc @safe delete(void* p); } void templ(T)(T val) { diff --git a/test/compilable/extra-files/header1i.di b/test/compilable/extra-files/header1i.di index d949a64d4198..70d0ce62b236 100644 --- a/test/compilable/extra-files/header1i.di +++ b/test/compilable/extra-files/header1i.di @@ -347,13 +347,6 @@ class Test alias getHUShort = A!ushort; alias getHReal = A!real; alias void F(); - nothrow pure @nogc @safe new(size_t sz) - { - return null; - } - nothrow pure @nogc @safe delete(void* p) - { - } } void templ(T)(T val) { diff --git a/test/compilable/vgc1.d b/test/compilable/vgc1.d index 5dd0cd82daad..8a11657ac3d6 100644 --- a/test/compilable/vgc1.d +++ b/test/compilable/vgc1.d @@ -3,30 +3,20 @@ /***************** NewExp *******************/ -/* -TEST_OUTPUT: ---- -compilable/vgc1.d(17): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class -compilable/vgc1.d(18): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class ---- -*/ - struct S1 { } struct S2 { this(int); } struct S3 { this(int) @nogc; } -struct S4 { new(size_t); } -struct S5 { @nogc new(size_t); } /* TEST_OUTPUT: --- -compilable/vgc1.d(35): vgc: `new` causes a GC allocation -compilable/vgc1.d(37): vgc: `new` causes a GC allocation -compilable/vgc1.d(38): vgc: `new` causes a GC allocation -compilable/vgc1.d(40): 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(46): vgc: `new` causes a GC allocation +compilable/vgc1.d(25): vgc: `new` causes a GC allocation +compilable/vgc1.d(27): vgc: `new` causes a GC allocation +compilable/vgc1.d(28): vgc: `new` causes a GC allocation +compilable/vgc1.d(30): vgc: `new` causes a GC allocation +compilable/vgc1.d(31): vgc: `new` causes a GC allocation +compilable/vgc1.d(32): vgc: `new` causes a GC allocation +compilable/vgc1.d(34): vgc: `new` causes a GC allocation --- */ @@ -40,8 +30,6 @@ void testNew() S1* ps1 = new S1(); S2* ps2 = new S2(1); S3* ps3 = new S3(1); - S4* ps4 = new S4; // no error - S5* ps5 = new S5; // no error Object o1 = new Object(); } @@ -49,12 +37,12 @@ void testNew() /* TEST_OUTPUT: --- -compilable/vgc1.d(63): vgc: `new` causes a GC allocation -compilable/vgc1.d(65): vgc: `new` causes a GC allocation -compilable/vgc1.d(66): vgc: `new` causes a GC allocation -compilable/vgc1.d(68): 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(51): vgc: `new` causes a GC allocation +compilable/vgc1.d(53): vgc: `new` causes a GC allocation +compilable/vgc1.d(54): vgc: `new` causes a GC allocation +compilable/vgc1.d(56): 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 --- */ @@ -68,8 +56,6 @@ void testNewScope() scope S1* ps1 = new S1(); scope S2* ps2 = new S2(1); scope S3* ps3 = new S3(1); - scope S4* ps4 = new S4; // no error - scope S5* ps5 = new S5; // no error scope Object o1 = new Object(); // no error scope o2 = new Object(); // no error @@ -82,12 +68,12 @@ void testNewScope() /* TEST_OUTPUT: --- -compilable/vgc1.d(95): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -compilable/vgc1.d(95): vgc: `delete` requires the GC -compilable/vgc1.d(96): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -compilable/vgc1.d(96): vgc: `delete` requires the GC -compilable/vgc1.d(97): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -compilable/vgc1.d(97): vgc: `delete` requires the GC +compilable/vgc1.d(81): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +compilable/vgc1.d(81): vgc: `delete` requires the GC +compilable/vgc1.d(82): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +compilable/vgc1.d(82): vgc: `delete` requires the GC +compilable/vgc1.d(83): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +compilable/vgc1.d(83): vgc: `delete` requires the GC --- */ void testDelete(int* p, Object o, S1* s) diff --git a/test/fail_compilation/diag_class_alloc.d b/test/fail_compilation/diag_class_alloc.d new file mode 100644 index 000000000000..272ca8b71a0e --- /dev/null +++ b/test/fail_compilation/diag_class_alloc.d @@ -0,0 +1,23 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag_class_alloc.d(14): Error: class allocators are obsolete, consider moving the allocation strategy outside of the class +fail_compilation/diag_class_alloc.d(19): Error: class deallocators are obsolete, consider moving the deallocation strategy outside of the class +--- +*/ + +// This test exists to ensure class allocators and deallocators emit an appropriate error message. +// This test can be deleted when class allocators and deallocators are removed from the language. + +class C +{ + new(size_t size) // error message + { + return malloc(size); + } + + delete(void* obj) // error message + { + free(obj); + } +} diff --git a/test/fail_compilation/fail14249.d b/test/fail_compilation/fail14249.d index 3eaeef7bc1fc..8d66a75c5c11 100644 --- a/test/fail_compilation/fail14249.d +++ b/test/fail_compilation/fail14249.d @@ -2,22 +2,18 @@ REQUIRED_ARGS: -unittest TEST_OUTPUT: --- -fail_compilation/fail14249.d(25): Error: `shared static` constructor can only be member of module/aggregate/template, not function `main` -fail_compilation/fail14249.d(26): Error: `shared static` destructor can only be member of module/aggregate/template, not function `main` -fail_compilation/fail14249.d(27): Error: `static` constructor can only be member of module/aggregate/template, not function `main` -fail_compilation/fail14249.d(28): Error: `static` destructor can only be member of module/aggregate/template, not function `main` -fail_compilation/fail14249.d(29): Error: `unittest` can only be a member of module/aggregate/template, not function `main` -fail_compilation/fail14249.d(30): Error: `invariant` can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(31): Error: alias this can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(32): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class -fail_compilation/fail14249.d(32): Error: allocator can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(33): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14249.d(33): Error: deallocator can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(34): Error: constructor can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(35): Error: destructor can only be a member of aggregate, not function `main` -fail_compilation/fail14249.d(36): Error: postblit can only be a member of struct, not function `main` -fail_compilation/fail14249.d(37): Error: anonymous union can only be a part of an aggregate, not function `main` -fail_compilation/fail14249.d(41): Error: mixin `fail14249.main.Mix!()` error instantiating +fail_compilation/fail14249.d(21): Error: `shared static` constructor can only be member of module/aggregate/template, not function `main` +fail_compilation/fail14249.d(22): Error: `shared static` destructor can only be member of module/aggregate/template, not function `main` +fail_compilation/fail14249.d(23): Error: `static` constructor can only be member of module/aggregate/template, not function `main` +fail_compilation/fail14249.d(24): Error: `static` destructor can only be member of module/aggregate/template, not function `main` +fail_compilation/fail14249.d(25): Error: `unittest` can only be a member of module/aggregate/template, not function `main` +fail_compilation/fail14249.d(26): Error: `invariant` can only be a member of aggregate, not function `main` +fail_compilation/fail14249.d(27): Error: alias this can only be a member of aggregate, not function `main` +fail_compilation/fail14249.d(28): Error: constructor can only be a member of aggregate, not function `main` +fail_compilation/fail14249.d(29): Error: destructor can only be a member of aggregate, not function `main` +fail_compilation/fail14249.d(30): Error: postblit can only be a member of struct, not function `main` +fail_compilation/fail14249.d(31): Error: anonymous union can only be a part of an aggregate, not function `main` +fail_compilation/fail14249.d(35): Error: mixin `fail14249.main.Mix!()` error instantiating --- */ mixin template Mix() @@ -29,8 +25,6 @@ mixin template Mix() unittest {} invariant {} alias a this; - new(size_t sz) { return null; } - delete(void* p) { } this() {} // from fail268.d ~this() {} // from fail268.d this(this) {} diff --git a/test/fail_compilation/fail14407.d b/test/fail_compilation/fail14407.d deleted file mode 100644 index 3bdeea5912c4..000000000000 --- a/test/fail_compilation/fail14407.d +++ /dev/null @@ -1,51 +0,0 @@ -import imports.a14407; - -/* -TEST_OUTPUT: ---- -fail_compilation/fail14407.d(23): Deprecation: class `imports.a14407.C` is deprecated -fail_compilation/fail14407.d(23): Deprecation: allocator `imports.a14407.C.new` is deprecated -fail_compilation/fail14407.d(23): Error: `pure` function `fail14407.testC` cannot call impure allocator `imports.a14407.C.new` -fail_compilation/fail14407.d(23): Error: `@safe` function `fail14407.testC` cannot call `@system` allocator `imports.a14407.C.new` -fail_compilation/imports/a14407.d(5): `imports.a14407.C.new` is declared here -fail_compilation/fail14407.d(23): Error: `@nogc` function `fail14407.testC` cannot call non-@nogc allocator `imports.a14407.C.new` -fail_compilation/fail14407.d(23): Error: class `imports.a14407.C` member `new` is not accessible -fail_compilation/fail14407.d(23): Error: `pure` function `fail14407.testC` cannot call impure constructor `imports.a14407.C.this` -fail_compilation/fail14407.d(23): Error: `@safe` function `fail14407.testC` cannot call `@system` constructor `imports.a14407.C.this` -fail_compilation/imports/a14407.d(9): `imports.a14407.C.this` is declared here -fail_compilation/fail14407.d(23): Error: `@nogc` function `fail14407.testC` cannot call non-@nogc constructor `imports.a14407.C.this` -fail_compilation/fail14407.d(23): Error: class `imports.a14407.C` member `this` is not accessible -fail_compilation/fail14407.d(23): Error: allocator `imports.a14407.C.new` is not `nothrow` ---- -*/ -void testC() pure nothrow @safe @nogc -{ - new("arg") C(0); -} - -/* -TEST_OUTPUT: ---- -fail_compilation/fail14407.d(23): Error: constructor `imports.a14407.C.this` is not `nothrow` -fail_compilation/fail14407.d(21): Error: `nothrow` function `fail14407.testC` may throw -fail_compilation/fail14407.d(50): Deprecation: struct `imports.a14407.S` is deprecated -fail_compilation/fail14407.d(50): Deprecation: allocator `imports.a14407.S.new` is deprecated -fail_compilation/fail14407.d(50): Error: `pure` function `fail14407.testS` cannot call impure allocator `imports.a14407.S.new` -fail_compilation/fail14407.d(50): Error: `@safe` function `fail14407.testS` cannot call `@system` allocator `imports.a14407.S.new` -fail_compilation/imports/a14407.d(14): `imports.a14407.S.new` is declared here -fail_compilation/fail14407.d(50): Error: `@nogc` function `fail14407.testS` cannot call non-@nogc allocator `imports.a14407.S.new` -fail_compilation/fail14407.d(50): Error: struct `imports.a14407.S` member `new` is not accessible -fail_compilation/fail14407.d(50): Error: `pure` function `fail14407.testS` cannot call impure constructor `imports.a14407.S.this` -fail_compilation/fail14407.d(50): Error: `@safe` function `fail14407.testS` cannot call `@system` constructor `imports.a14407.S.this` -fail_compilation/imports/a14407.d(18): `imports.a14407.S.this` is declared here -fail_compilation/fail14407.d(50): Error: `@nogc` function `fail14407.testS` cannot call non-@nogc constructor `imports.a14407.S.this` -fail_compilation/fail14407.d(50): Error: struct `imports.a14407.S` member `this` is not accessible -fail_compilation/fail14407.d(50): Error: allocator `imports.a14407.S.new` is not `nothrow` -fail_compilation/fail14407.d(50): Error: constructor `imports.a14407.S.this` is not `nothrow` -fail_compilation/fail14407.d(48): Error: `nothrow` function `fail14407.testS` may throw ---- -*/ -void testS() pure nothrow @safe @nogc -{ - new("arg") S(0); -} diff --git a/test/fail_compilation/fail14486.d b/test/fail_compilation/fail14486.d index c5bb941d8299..07152f4bb45b 100644 --- a/test/fail_compilation/fail14486.d +++ b/test/fail_compilation/fail14486.d @@ -3,174 +3,86 @@ /* TEST_OUTPUT: --- -fail_compilation/fail14486.d(102): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(103): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(104): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(108): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(109): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(110): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(114): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(115): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(116): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(120): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(121): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(122): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail14486.d(126): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(126): Error: `delete c0` is not `@safe` but is used in `@safe` function `test1a` -fail_compilation/fail14486.d(127): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(127): Error: `pure` function `fail14486.test1a` cannot call impure destructor `fail14486.C1a.~this` -fail_compilation/fail14486.d(127): Error: `@safe` function `fail14486.test1a` cannot call `@system` destructor `fail14486.C1a.~this` -fail_compilation/fail14486.d(101): `fail14486.C1a.~this` is declared here -fail_compilation/fail14486.d(127): Error: `@nogc` function `fail14486.test1a` cannot call non-@nogc destructor `fail14486.C1a.~this` -fail_compilation/fail14486.d(128): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(128): Error: `pure` function `fail14486.test1a` cannot call impure destructor `fail14486.C2a.~this` -fail_compilation/fail14486.d(128): Error: `@safe` function `fail14486.test1a` cannot call `@system` destructor `fail14486.C2a.~this` -fail_compilation/fail14486.d(102): `fail14486.C2a.~this` is declared here -fail_compilation/fail14486.d(128): Error: `@nogc` function `fail14486.test1a` cannot call non-@nogc destructor `fail14486.C2a.~this` -fail_compilation/fail14486.d(129): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(129): Error: `pure` function `fail14486.test1a` cannot call impure deallocator `fail14486.C3a.delete` -fail_compilation/fail14486.d(129): Error: `@safe` function `fail14486.test1a` cannot call `@system` deallocator `fail14486.C3a.delete` -fail_compilation/fail14486.d(103): `fail14486.C3a.delete` is declared here -fail_compilation/fail14486.d(129): Error: `@nogc` function `fail14486.test1a` cannot call non-@nogc deallocator `fail14486.C3a.delete` -fail_compilation/fail14486.d(130): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(130): Error: `delete c4` is not `@safe` but is used in `@safe` function `test1a` -fail_compilation/fail14486.d(135): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(136): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(137): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(138): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(139): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(136): Error: destructor `fail14486.C1b.~this` is not `nothrow` -fail_compilation/fail14486.d(137): Error: destructor `fail14486.C2b.~this` is not `nothrow` -fail_compilation/fail14486.d(138): Error: deallocator `fail14486.C3b.delete` is not `nothrow` -fail_compilation/fail14486.d(133): Error: `nothrow` function `fail14486.test1b` may throw -fail_compilation/fail14486.d(144): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(144): Error: `delete s0` is not `@safe` but is used in `@safe` function `test2a` -fail_compilation/fail14486.d(145): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(145): Error: `pure` function `fail14486.test2a` cannot call impure destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(145): Error: `@safe` function `fail14486.test2a` cannot call `@system` destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(113): `fail14486.S1a.~this` is declared here -fail_compilation/fail14486.d(145): Error: `@nogc` function `fail14486.test2a` cannot call non-@nogc destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(146): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(146): Error: `pure` function `fail14486.test2a` cannot call impure destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(146): Error: `@safe` function `fail14486.test2a` cannot call `@system` destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(114): `fail14486.S2a.~this` is declared here -fail_compilation/fail14486.d(146): Error: `@nogc` function `fail14486.test2a` cannot call non-@nogc destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(147): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(147): Error: `pure` function `fail14486.test2a` cannot call impure deallocator `fail14486.S3a.delete` -fail_compilation/fail14486.d(147): Error: `@safe` function `fail14486.test2a` cannot call `@system` deallocator `fail14486.S3a.delete` -fail_compilation/fail14486.d(115): `fail14486.S3a.delete` is declared here -fail_compilation/fail14486.d(147): Error: `@nogc` function `fail14486.test2a` cannot call non-@nogc deallocator `fail14486.S3a.delete` -fail_compilation/fail14486.d(148): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(153): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(154): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(155): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(156): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(157): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(154): Error: destructor `fail14486.S1b.~this` is not `nothrow` -fail_compilation/fail14486.d(155): Error: destructor `fail14486.S2b.~this` is not `nothrow` -fail_compilation/fail14486.d(156): Error: deallocator `fail14486.S3b.delete` is not `nothrow` -fail_compilation/fail14486.d(151): Error: `nothrow` function `fail14486.test2b` may throw -fail_compilation/fail14486.d(162): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(162): Error: `delete a0` is not `@safe` but is used in `@safe` function `test3a` -fail_compilation/fail14486.d(163): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(163): Error: `pure` function `fail14486.test3a` cannot call impure destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(163): Error: `@safe` function `fail14486.test3a` cannot call `@system` destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(113): `fail14486.S1a.~this` is declared here -fail_compilation/fail14486.d(163): Error: `@nogc` function `fail14486.test3a` cannot call non-@nogc destructor `fail14486.S1a.~this` -fail_compilation/fail14486.d(164): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(164): Error: `pure` function `fail14486.test3a` cannot call impure destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(164): Error: `@safe` function `fail14486.test3a` cannot call `@system` destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(114): `fail14486.S2a.~this` is declared here -fail_compilation/fail14486.d(164): Error: `@nogc` function `fail14486.test3a` cannot call non-@nogc destructor `fail14486.S2a.~this` -fail_compilation/fail14486.d(165): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(165): Error: `delete a3` is not `@safe` but is used in `@safe` function `test3a` -fail_compilation/fail14486.d(166): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(166): Error: `delete a4` is not `@safe` but is used in `@safe` function `test3a` -fail_compilation/fail14486.d(171): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(172): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(173): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(174): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(175): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/fail14486.d(172): Error: destructor `fail14486.S1b.~this` is not `nothrow` -fail_compilation/fail14486.d(173): Error: destructor `fail14486.S2b.~this` is not `nothrow` -fail_compilation/fail14486.d(169): Error: `nothrow` function `fail14486.test3b` may throw +fail_compilation/fail14486.d(56): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(56): Error: `delete c0` is not `@safe` but is used in `@safe` function `test1a` +fail_compilation/fail14486.d(57): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(57): Error: `pure` function `fail14486.test1a` cannot call impure destructor `fail14486.C1a.~this` +fail_compilation/fail14486.d(57): Error: `@safe` function `fail14486.test1a` cannot call `@system` destructor `fail14486.C1a.~this` +fail_compilation/fail14486.d(43): `fail14486.C1a.~this` is declared here +fail_compilation/fail14486.d(57): Error: `@nogc` function `fail14486.test1a` cannot call non-@nogc destructor `fail14486.C1a.~this` +fail_compilation/fail14486.d(62): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(63): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(63): Error: destructor `fail14486.C1b.~this` is not `nothrow` +fail_compilation/fail14486.d(60): Error: `nothrow` function `fail14486.test1b` may throw +fail_compilation/fail14486.d(68): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(68): Error: `delete s0` is not `@safe` but is used in `@safe` function `test2a` +fail_compilation/fail14486.d(69): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(69): Error: `pure` function `fail14486.test2a` cannot call impure destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(69): Error: `@safe` function `fail14486.test2a` cannot call `@system` destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(49): `fail14486.S1a.~this` is declared here +fail_compilation/fail14486.d(69): Error: `@nogc` function `fail14486.test2a` cannot call non-@nogc destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(74): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(75): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(75): Error: destructor `fail14486.S1b.~this` is not `nothrow` +fail_compilation/fail14486.d(72): Error: `nothrow` function `fail14486.test2b` may throw +fail_compilation/fail14486.d(80): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(80): Error: `delete a0` is not `@safe` but is used in `@safe` function `test3a` +fail_compilation/fail14486.d(81): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(81): Error: `pure` function `fail14486.test3a` cannot call impure destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(81): Error: `@safe` function `fail14486.test3a` cannot call `@system` destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(49): `fail14486.S1a.~this` is declared here +fail_compilation/fail14486.d(81): Error: `@nogc` function `fail14486.test3a` cannot call non-@nogc destructor `fail14486.S1a.~this` +fail_compilation/fail14486.d(86): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(87): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/fail14486.d(87): Error: destructor `fail14486.S1b.~this` is not `nothrow` +fail_compilation/fail14486.d(84): Error: `nothrow` function `fail14486.test3b` may throw --- */ class C0a { } class C1a { ~this() {} } -class C2a { ~this() {} @nogc pure @safe delete(void* p) {} } -class C3a { @nogc pure @safe ~this() {} delete(void* p) {} } -class C4a { @nogc pure @safe ~this() {} @nogc pure @safe delete(void* p) {} } class C0b { } class C1b { ~this() {} } -class C2b { ~this() {} nothrow delete(void* p) {} } -class C3b { nothrow ~this() {} delete(void* p) {} } -class C4b { nothrow ~this() {} nothrow delete(void* p) {} } struct S0a { } struct S1a { ~this() {} } -struct S2a { ~this() {} @nogc pure @safe delete(void* p) {} } -struct S3a { @nogc pure @safe ~this() {} delete(void* p) {} } -struct S4a { @nogc pure @safe ~this() {} @nogc pure @safe delete(void* p) {} } struct S0b { } struct S1b { ~this() {} } -struct S2b { ~this() {} nothrow delete(void* p) {} } -struct S3b { nothrow ~this() {} delete(void* p) {} } -struct S4b { nothrow ~this() {} nothrow delete(void* p) {} } void test1a() @nogc pure @safe { C0a c0; delete c0; // error C1a c1; delete c1; // error - C2a c2; delete c2; // error - C3a c3; delete c3; // error - C4a c4; delete c4; // no error } void test1b() nothrow { C0b c0; delete c0; // no error C1b c1; delete c1; // error - C2b c2; delete c2; // error - C3b c3; delete c3; // error - C4b c4; delete c4; // no error } void test2a() @nogc pure @safe { S0a* s0; delete s0; // error S1a* s1; delete s1; // error - S2a* s2; delete s2; // error - S3a* s3; delete s3; // error - S4a* s4; delete s4; // no error } void test2b() nothrow { S0b* s0; delete s0; // no error S1b* s1; delete s1; // error - S2b* s2; delete s2; // error - S3b* s3; delete s3; // error - S4b* s4; delete s4; // no error } void test3a() @nogc pure @safe { S0a[] a0; delete a0; // error S1a[] a1; delete a1; // error - S2a[] a2; delete a2; // error - S3a[] a3; delete a3; // error - S4a[] a4; delete a4; // error } void test3b() nothrow { S0b[] a0; delete a0; // no error S1b[] a1; delete a1; // error - S2b[] a2; delete a2; // error - S3b[] a3; delete a3; // no error - S4b[] a4; delete a4; // no error } diff --git a/test/fail_compilation/fail7848.d b/test/fail_compilation/fail7848.d index ec90899f2131..4fc269eed4c7 100644 --- a/test/fail_compilation/fail7848.d +++ b/test/fail_compilation/fail7848.d @@ -3,32 +3,18 @@ /* TEST_OUTPUT: --- -fail_compilation/fail7848.d(49): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class -fail_compilation/fail7848.d(55): Deprecation: class deallocators have been deprecated, consider moving the deallocation strategy outside of the class -fail_compilation/fail7848.d(41): Error: `pure` function `fail7848.C.__unittest_L39_C30` cannot call impure function `fail7848.func` -fail_compilation/fail7848.d(41): Error: `@safe` function `fail7848.C.__unittest_L39_C30` cannot call `@system` function `fail7848.func` -fail_compilation/fail7848.d(35): `fail7848.func` is declared here -fail_compilation/fail7848.d(41): Error: `@nogc` function `fail7848.C.__unittest_L39_C30` cannot call non-@nogc function `fail7848.func` -fail_compilation/fail7848.d(41): Error: function `fail7848.func` is not `nothrow` -fail_compilation/fail7848.d(39): Error: `nothrow` function `fail7848.C.__unittest_L39_C30` may throw -fail_compilation/fail7848.d(46): Error: `pure` function `fail7848.C.__invariant1` cannot call impure function `fail7848.func` -fail_compilation/fail7848.d(46): Error: `@safe` function `fail7848.C.__invariant1` cannot call `@system` function `fail7848.func` -fail_compilation/fail7848.d(35): `fail7848.func` is declared here -fail_compilation/fail7848.d(46): Error: `@nogc` function `fail7848.C.__invariant1` cannot call non-@nogc function `fail7848.func` -fail_compilation/fail7848.d(46): Error: function `fail7848.func` is not `nothrow` -fail_compilation/fail7848.d(44): Error: `nothrow` function `fail7848.C.__invariant1` may throw -fail_compilation/fail7848.d(51): Error: `pure` allocator `fail7848.C.new` cannot call impure function `fail7848.func` -fail_compilation/fail7848.d(51): Error: `@safe` allocator `fail7848.C.new` cannot call `@system` function `fail7848.func` -fail_compilation/fail7848.d(35): `fail7848.func` is declared here -fail_compilation/fail7848.d(51): Error: `@nogc` allocator `fail7848.C.new` cannot call non-@nogc function `fail7848.func` -fail_compilation/fail7848.d(51): Error: function `fail7848.func` is not `nothrow` -fail_compilation/fail7848.d(49): Error: `nothrow` allocator `fail7848.C.new` may throw -fail_compilation/fail7848.d(57): Error: `pure` deallocator `fail7848.C.delete` cannot call impure function `fail7848.func` -fail_compilation/fail7848.d(57): Error: `@safe` deallocator `fail7848.C.delete` cannot call `@system` function `fail7848.func` -fail_compilation/fail7848.d(35): `fail7848.func` is declared here -fail_compilation/fail7848.d(57): Error: `@nogc` deallocator `fail7848.C.delete` cannot call non-@nogc function `fail7848.func` -fail_compilation/fail7848.d(57): Error: function `fail7848.func` is not `nothrow` -fail_compilation/fail7848.d(55): Error: `nothrow` deallocator `fail7848.C.delete` may throw +fail_compilation/fail7848.d(27): Error: `pure` function `fail7848.C.__unittest_L25_C30` cannot call impure function `fail7848.func` +fail_compilation/fail7848.d(27): Error: `@safe` function `fail7848.C.__unittest_L25_C30` cannot call `@system` function `fail7848.func` +fail_compilation/fail7848.d(21): `fail7848.func` is declared here +fail_compilation/fail7848.d(27): Error: `@nogc` function `fail7848.C.__unittest_L25_C30` cannot call non-@nogc function `fail7848.func` +fail_compilation/fail7848.d(27): Error: function `fail7848.func` is not `nothrow` +fail_compilation/fail7848.d(25): Error: `nothrow` function `fail7848.C.__unittest_L25_C30` may throw +fail_compilation/fail7848.d(32): Error: `pure` function `fail7848.C.__invariant1` cannot call impure function `fail7848.func` +fail_compilation/fail7848.d(32): Error: `@safe` function `fail7848.C.__invariant1` cannot call `@system` function `fail7848.func` +fail_compilation/fail7848.d(21): `fail7848.func` is declared here +fail_compilation/fail7848.d(32): Error: `@nogc` function `fail7848.C.__invariant1` cannot call non-@nogc function `fail7848.func` +fail_compilation/fail7848.d(32): Error: function `fail7848.func` is not `nothrow` +fail_compilation/fail7848.d(30): Error: `nothrow` function `fail7848.C.__invariant1` may throw --- */ @@ -45,15 +31,4 @@ class C { func(); } - - @safe pure nothrow @nogc new (size_t sz) - { - func(); - return null; - } - - @safe pure nothrow @nogc delete (void* p) - { - func(); - } } diff --git a/test/fail_compilation/failmemalloc.d b/test/fail_compilation/failmemalloc.d deleted file mode 100644 index b2806cf1ab3b..000000000000 --- a/test/fail_compilation/failmemalloc.d +++ /dev/null @@ -1,14 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/failmemalloc.d(11): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class -fail_compilation/failmemalloc.d(14): Error: member allocators not supported by CTFE ---- -*/ - -struct S -{ - new(size_t sz) { return null; } -} - -S* s = new S(); diff --git a/test/fail_compilation/imports/a14407.d b/test/fail_compilation/imports/a14407.d deleted file mode 100644 index d906bc744040..000000000000 --- a/test/fail_compilation/imports/a14407.d +++ /dev/null @@ -1,19 +0,0 @@ -module imports.a14407; - -deprecated class C -{ - private deprecated new (size_t, string) - { - return null; - } - private this(int) {} -} - -deprecated struct S -{ - private deprecated new (size_t, string) - { - return null; - } - private this(int) {} -} diff --git a/test/fail_compilation/nogc1.d b/test/fail_compilation/nogc1.d index 3a3fe70c3fd9..9519a3d7dc89 100644 --- a/test/fail_compilation/nogc1.d +++ b/test/fail_compilation/nogc1.d @@ -3,31 +3,20 @@ /***************** NewExp *******************/ -/* -TEST_OUTPUT: ---- -fail_compilation/nogc1.d(17): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class -fail_compilation/nogc1.d(18): Deprecation: class allocators have been deprecated, consider moving the allocation strategy outside of the class ---- -*/ - struct S1 { } struct S2 { this(int); } struct S3 { this(int) @nogc; } -struct S4 { new(size_t); } -struct S5 { @nogc new(size_t); } /* TEST_OUTPUT: --- -fail_compilation/nogc1.d(35): Error: cannot use `new` in `@nogc` function `nogc1.testNew` -fail_compilation/nogc1.d(37): Error: cannot use `new` in `@nogc` function `nogc1.testNew` -fail_compilation/nogc1.d(38): Error: cannot use `new` in `@nogc` function `nogc1.testNew` -fail_compilation/nogc1.d(40): Error: cannot use `new` in `@nogc` function `nogc1.testNew` -fail_compilation/nogc1.d(41): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc constructor `nogc1.S2.this` -fail_compilation/nogc1.d(42): Error: cannot use `new` in `@nogc` function `nogc1.testNew` -fail_compilation/nogc1.d(43): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc allocator `nogc1.S4.new` -fail_compilation/nogc1.d(46): Error: cannot use `new` in `@nogc` function `nogc1.testNew` +fail_compilation/nogc1.d(24): Error: cannot use `new` in `@nogc` function `nogc1.testNew` +fail_compilation/nogc1.d(26): 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: `@nogc` function `nogc1.testNew` cannot call non-@nogc constructor `nogc1.S2.this` +fail_compilation/nogc1.d(31): Error: cannot use `new` in `@nogc` function `nogc1.testNew` +fail_compilation/nogc1.d(33): Error: cannot use `new` in `@nogc` function `nogc1.testNew` --- */ @nogc void testNew() @@ -40,8 +29,6 @@ fail_compilation/nogc1.d(46): Error: cannot use `new` in `@nogc` function `nogc1 S1* ps1 = new S1(); S2* ps2 = new S2(1); S3* ps3 = new S3(1); - S4* ps4 = new S4; - S5* ps5 = new S5; // no error Object o1 = new Object(); } @@ -49,13 +36,12 @@ fail_compilation/nogc1.d(46): Error: cannot use `new` in `@nogc` function `nogc1 /* TEST_OUTPUT: --- -fail_compilation/nogc1.d(63): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` -fail_compilation/nogc1.d(65): 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(68): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` -fail_compilation/nogc1.d(69): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc constructor `nogc1.S2.this` -fail_compilation/nogc1.d(70): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` -fail_compilation/nogc1.d(71): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc allocator `nogc1.S4.new` +fail_compilation/nogc1.d(49): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` +fail_compilation/nogc1.d(51): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` +fail_compilation/nogc1.d(52): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` +fail_compilation/nogc1.d(54): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` +fail_compilation/nogc1.d(55): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc constructor `nogc1.S2.this` +fail_compilation/nogc1.d(56): Error: cannot use `new` in `@nogc` function `nogc1.testNewScope` --- */ @nogc void testNewScope() @@ -68,8 +54,6 @@ fail_compilation/nogc1.d(71): Error: `@nogc` function `nogc1.testNewScope` canno scope S1* ps1 = new S1(); scope S2* ps2 = new S2(1); scope S3* ps3 = new S3(1); - scope S4* ps4 = new S4; - scope S5* ps5 = new S5; // no error scope Object o1 = new Object(); // no error scope o2 = new Object(); // no error @@ -80,12 +64,12 @@ fail_compilation/nogc1.d(71): Error: `@nogc` function `nogc1.testNewScope` canno /* TEST_OUTPUT: --- -fail_compilation/nogc1.d(93): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/nogc1.d(93): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` -fail_compilation/nogc1.d(94): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/nogc1.d(94): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` -fail_compilation/nogc1.d(95): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. -fail_compilation/nogc1.d(95): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` +fail_compilation/nogc1.d(77): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/nogc1.d(77): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` +fail_compilation/nogc1.d(78): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/nogc1.d(78): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` +fail_compilation/nogc1.d(79): Deprecation: The `delete` keyword has been deprecated. Use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead. +fail_compilation/nogc1.d(79): Error: cannot use `delete` in `@nogc` function `nogc1.testDelete` --- */ @nogc void testDelete(int* p, Object o, S1* s) diff --git a/test/runnable/newdel.d b/test/runnable/newdel.d index 21f7809c6840..a20acc454fc3 100644 --- a/test/runnable/newdel.d +++ b/test/runnable/newdel.d @@ -9,18 +9,6 @@ class Foo { static uint flags; - new(size_t sz, int x) - { void* p; - - printf("Foo.new(sz = %d, x = %d)\n", sz, x); - assert(sz == Foo.classinfo.initializer.length); - assert(x == 5); - - p = core.stdc.stdlib.malloc(sz); - flags |= 4; - return p; - } - this() { printf("this() %p\n", this); @@ -34,13 +22,6 @@ class Foo flags |= 1; } - delete(void* p) - { - printf("delete %p\n", p); - free(p); - flags |= 2; - } - int a = 3; int b = 4; int d = 56; @@ -50,59 +31,21 @@ void test1() { Foo f; - f = new(5) Foo; + f = new Foo(); assert(f.a == 36); assert(f.b == 4); assert(f.d == 56); - assert(Foo.flags == 4); + assert(Foo.flags == 0); delete f; - assert(Foo.flags == 7); + assert(Foo.flags == 1); } - -/*********************************************/ - -struct Foo2 -{ - static uint flags; - - new(size_t sz, int x) - { void* p; - - printf("Foo2.new(sz = %d, x = %d)\n", sz, x); - assert(sz == Foo2.sizeof); - assert(x == 5); - - p = core.stdc.stdlib.malloc(sz); - flags |= 4; - return p; - } - - delete(void *p) - { - printf("p = %p\n", p); - flags |= 2; - core.stdc.stdlib.free(p); - } -} - -void test2() -{ - Foo2 *f = new(5) Foo2(); - - printf("f = %p\n", f); - delete f; - assert(Foo2.flags == 6); -} - - /*********************************************/ int main() { test1(); - test2(); printf("Success\n"); return 0; diff --git a/test/runnable/sdtor.d b/test/runnable/sdtor.d index 46d2d6f793c4..d09f488acb13 100644 --- a/test/runnable/sdtor.d +++ b/test/runnable/sdtor.d @@ -25,23 +25,6 @@ void test1() /**********************************/ -int sdtor2; - -struct S2 -{ - ~this() { printf("~S2()\n"); sdtor2++; } - delete(void* p) { assert(sdtor2 == 1); printf("S2.delete()\n"); sdtor2++; } -} - -void test2() -{ - S2* s = new S2(); - delete s; - assert(sdtor2 == 2); -} - -/**********************************/ - int sdtor3; struct S3 @@ -4680,7 +4663,7 @@ void test19676() int main() { test1(); - test2(); + test3(); test4(); test5(); diff --git a/test/runnable/test20.d b/test/runnable/test20.d index cfb1eb469be4..a1478aa9901b 100644 --- a/test/runnable/test20.d +++ b/test/runnable/test20.d @@ -334,12 +334,6 @@ int y16; class C16 { - new(size_t size, byte blah){ - void* v = (new byte[C16.classinfo.initializer.length]).ptr; - y16 = 1; - assert(blah == 3); - return v; - } int x; this() { @@ -349,8 +343,7 @@ class C16 void test16() { - C16 c = new(3) C16; - assert(y16 == 1); + C16 c = new C16(); assert(c.x == 4); } diff --git a/test/runnable/test23.d b/test/runnable/test23.d index f43f6a460916..e6c8da89524d 100644 --- a/test/runnable/test23.d +++ b/test/runnable/test23.d @@ -702,72 +702,6 @@ void test31() /*******************************************/ -class Foo32 -{ - static void* ps; - - new (size_t sz) - { - void* p = core.stdc.stdlib.malloc(sz); - printf("new(sz = %d) = %p\n", sz, p); - ps = p; - return p; - } - - delete(void* p) - { - printf("delete(p = %p)\n", p); - assert(p == ps); - if (p) core.stdc.stdlib.free(p); - } -} - -void test32() -{ - Foo32 f = new Foo32; - delete f; -} - -/*******************************************/ - -class Foo33 -{ -// this() { printf("this()\n"); } -// ~this() { printf("~this()\n"); } - - static void* ps; - static int del; - - new (size_t sz, int i) - { - void* p = core.stdc.stdlib.malloc(sz); - printf("new(sz = %d) = %p\n", sz, p); - ps = p; - return p; - } - - delete(void* p) - { - printf("delete(p = %p)\n", p); - assert(p == ps); - if (p) core.stdc.stdlib.free(p); - del += 1; - } -} - -void foo33() -{ - scope Foo33 f = new(3) Foo33; -} - -void test33() -{ - foo33(); - assert(Foo33.del == 1); -} - -/*******************************************/ - struct o_O { int a; } union O_O { int a; } class O_o { int a; } @@ -1529,8 +1463,8 @@ void main() test29(); test30(); test31(); - test32(); - test33(); + + test34(); test37(); test38(); diff --git a/test/runnable/testdstress.d b/test/runnable/testdstress.d index c32eb8e41ccb..c7f5ba69129b 100644 --- a/test/runnable/testdstress.d +++ b/test/runnable/testdstress.d @@ -844,15 +844,8 @@ int counter41; class C41{ this(){ printf("this: counter41 = %d\n", counter41); - assert(counter41==1); - counter41+=2; - } - - new(size_t size){ - printf("new: size = %d\n", size); assert(counter41==0); - counter41++; - return malloc(size); + counter41+=2; } } @@ -861,7 +854,7 @@ void test41() C41 c; assert(counter41==0); c = new C41(); - assert(counter41==3); + assert(counter41==2); } /* ================================ */ diff --git a/test/runnable/xtest46.d b/test/runnable/xtest46.d index ae5889ef5cd5..093bfb31f430 100644 --- a/test/runnable/xtest46.d +++ b/test/runnable/xtest46.d @@ -2553,21 +2553,6 @@ void test124() { /***************************************************/ -void test3022() -{ - static class Foo3022 - { - new(size_t) - { - assert(0); - } - } - - scope x = new Foo3022; -} - -/***************************************************/ - void doNothing() {} void bug5071(short d, ref short c) { @@ -8228,7 +8213,7 @@ int main() test6733(); test6813(); test6859(); - test3022(); + test6910(); test6902(); test6330();