-
-
Notifications
You must be signed in to change notification settings - Fork 686
Advance deprecation of class allocators and deallocators: Removal #9786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of changing line numbers again, can we use a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating the test output is fully automated, so this is less work (: |
||
| --- | ||
| */ | ||
|
|
||
|
|
@@ -40,21 +30,19 @@ 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(); | ||
| } | ||
|
|
||
| /* | ||
| 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) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.