mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
Make delete
an identifier instead of keyword (#20745)
This commit is contained in:
parent
f60fc38312
commit
096c9c1528
17 changed files with 246 additions and 417 deletions
15
changelog/dmd.delete-keyword.dd
Normal file
15
changelog/dmd.delete-keyword.dd
Normal file
|
@ -0,0 +1,15 @@
|
|||
`delete` is no longer a keyword
|
||||
|
||||
After being superseded by `destroy()`, deprecated, and turned into an error, the keyword can now be used as an identifier:
|
||||
|
||||
---
|
||||
enum Action
|
||||
{
|
||||
add, delete
|
||||
}
|
||||
|
||||
void delete(T)(T obj)
|
||||
{
|
||||
|
||||
}
|
||||
---
|
|
@ -8975,17 +8975,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
|
||||
override void visit(DeleteExp exp)
|
||||
{
|
||||
// @@@DEPRECATED_2.109@@@
|
||||
// 1. Deprecated since 2.079
|
||||
// 2. Error since 2.099
|
||||
// 3. Removal of keyword, "delete" can be used for other identities
|
||||
if (!exp.isRAII)
|
||||
{
|
||||
error(exp.loc, "the `delete` keyword is obsolete");
|
||||
errorSupplemental(exp.loc, "use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead");
|
||||
return setError();
|
||||
}
|
||||
|
||||
Expression e = exp;
|
||||
|
||||
if (Expression ex = unaSemantic(exp, sc))
|
||||
|
|
|
@ -2810,215 +2810,214 @@ enum class TOK : uint8_t
|
|||
false_ = 15u,
|
||||
throw_ = 16u,
|
||||
new_ = 17u,
|
||||
delete_ = 18u,
|
||||
variable = 19u,
|
||||
slice = 20u,
|
||||
version_ = 21u,
|
||||
module_ = 22u,
|
||||
dollar = 23u,
|
||||
template_ = 24u,
|
||||
typeof_ = 25u,
|
||||
pragma_ = 26u,
|
||||
typeid_ = 27u,
|
||||
comment = 28u,
|
||||
lessThan = 29u,
|
||||
greaterThan = 30u,
|
||||
lessOrEqual = 31u,
|
||||
greaterOrEqual = 32u,
|
||||
equal = 33u,
|
||||
notEqual = 34u,
|
||||
identity = 35u,
|
||||
notIdentity = 36u,
|
||||
is_ = 37u,
|
||||
leftShift = 38u,
|
||||
rightShift = 39u,
|
||||
leftShiftAssign = 40u,
|
||||
rightShiftAssign = 41u,
|
||||
unsignedRightShift = 42u,
|
||||
unsignedRightShiftAssign = 43u,
|
||||
concatenateAssign = 44u,
|
||||
add = 45u,
|
||||
min = 46u,
|
||||
addAssign = 47u,
|
||||
minAssign = 48u,
|
||||
mul = 49u,
|
||||
div = 50u,
|
||||
mod = 51u,
|
||||
mulAssign = 52u,
|
||||
divAssign = 53u,
|
||||
modAssign = 54u,
|
||||
and_ = 55u,
|
||||
or_ = 56u,
|
||||
xor_ = 57u,
|
||||
andAssign = 58u,
|
||||
orAssign = 59u,
|
||||
xorAssign = 60u,
|
||||
assign = 61u,
|
||||
not_ = 62u,
|
||||
tilde = 63u,
|
||||
plusPlus = 64u,
|
||||
minusMinus = 65u,
|
||||
dot = 66u,
|
||||
comma = 67u,
|
||||
question = 68u,
|
||||
andAnd = 69u,
|
||||
orOr = 70u,
|
||||
int32Literal = 71u,
|
||||
uns32Literal = 72u,
|
||||
int64Literal = 73u,
|
||||
uns64Literal = 74u,
|
||||
int128Literal = 75u,
|
||||
uns128Literal = 76u,
|
||||
float32Literal = 77u,
|
||||
float64Literal = 78u,
|
||||
float80Literal = 79u,
|
||||
imaginary32Literal = 80u,
|
||||
imaginary64Literal = 81u,
|
||||
imaginary80Literal = 82u,
|
||||
charLiteral = 83u,
|
||||
wcharLiteral = 84u,
|
||||
dcharLiteral = 85u,
|
||||
identifier = 86u,
|
||||
string_ = 87u,
|
||||
interpolated = 88u,
|
||||
hexadecimalString = 89u,
|
||||
this_ = 90u,
|
||||
super_ = 91u,
|
||||
error = 92u,
|
||||
void_ = 93u,
|
||||
int8 = 94u,
|
||||
uns8 = 95u,
|
||||
int16 = 96u,
|
||||
uns16 = 97u,
|
||||
int32 = 98u,
|
||||
uns32 = 99u,
|
||||
int64 = 100u,
|
||||
uns64 = 101u,
|
||||
int128 = 102u,
|
||||
uns128 = 103u,
|
||||
float32 = 104u,
|
||||
float64 = 105u,
|
||||
float80 = 106u,
|
||||
imaginary32 = 107u,
|
||||
imaginary64 = 108u,
|
||||
imaginary80 = 109u,
|
||||
complex32 = 110u,
|
||||
complex64 = 111u,
|
||||
complex80 = 112u,
|
||||
char_ = 113u,
|
||||
wchar_ = 114u,
|
||||
dchar_ = 115u,
|
||||
bool_ = 116u,
|
||||
struct_ = 117u,
|
||||
class_ = 118u,
|
||||
interface_ = 119u,
|
||||
union_ = 120u,
|
||||
enum_ = 121u,
|
||||
import_ = 122u,
|
||||
alias_ = 123u,
|
||||
override_ = 124u,
|
||||
delegate_ = 125u,
|
||||
function_ = 126u,
|
||||
mixin_ = 127u,
|
||||
align_ = 128u,
|
||||
extern_ = 129u,
|
||||
private_ = 130u,
|
||||
protected_ = 131u,
|
||||
public_ = 132u,
|
||||
export_ = 133u,
|
||||
static_ = 134u,
|
||||
final_ = 135u,
|
||||
const_ = 136u,
|
||||
abstract_ = 137u,
|
||||
debug_ = 138u,
|
||||
deprecated_ = 139u,
|
||||
in_ = 140u,
|
||||
out_ = 141u,
|
||||
inout_ = 142u,
|
||||
lazy_ = 143u,
|
||||
auto_ = 144u,
|
||||
package_ = 145u,
|
||||
immutable_ = 146u,
|
||||
if_ = 147u,
|
||||
else_ = 148u,
|
||||
while_ = 149u,
|
||||
for_ = 150u,
|
||||
do_ = 151u,
|
||||
switch_ = 152u,
|
||||
case_ = 153u,
|
||||
default_ = 154u,
|
||||
break_ = 155u,
|
||||
continue_ = 156u,
|
||||
with_ = 157u,
|
||||
synchronized_ = 158u,
|
||||
return_ = 159u,
|
||||
goto_ = 160u,
|
||||
try_ = 161u,
|
||||
catch_ = 162u,
|
||||
finally_ = 163u,
|
||||
asm_ = 164u,
|
||||
foreach_ = 165u,
|
||||
foreach_reverse_ = 166u,
|
||||
scope_ = 167u,
|
||||
onScopeExit = 168u,
|
||||
onScopeFailure = 169u,
|
||||
onScopeSuccess = 170u,
|
||||
invariant_ = 171u,
|
||||
unittest_ = 172u,
|
||||
argumentTypes = 173u,
|
||||
ref_ = 174u,
|
||||
macro_ = 175u,
|
||||
parameters = 176u,
|
||||
traits = 177u,
|
||||
pure_ = 178u,
|
||||
nothrow_ = 179u,
|
||||
gshared = 180u,
|
||||
line = 181u,
|
||||
file = 182u,
|
||||
fileFullPath = 183u,
|
||||
moduleString = 184u,
|
||||
functionString = 185u,
|
||||
prettyFunction = 186u,
|
||||
shared_ = 187u,
|
||||
at = 188u,
|
||||
pow = 189u,
|
||||
powAssign = 190u,
|
||||
goesTo = 191u,
|
||||
vector = 192u,
|
||||
pound = 193u,
|
||||
arrow = 194u,
|
||||
colonColon = 195u,
|
||||
wchar_tLiteral = 196u,
|
||||
endOfLine = 197u,
|
||||
whitespace = 198u,
|
||||
rvalue = 199u,
|
||||
inline_ = 200u,
|
||||
register_ = 201u,
|
||||
restrict_ = 202u,
|
||||
signed_ = 203u,
|
||||
sizeof_ = 204u,
|
||||
typedef_ = 205u,
|
||||
unsigned_ = 206u,
|
||||
volatile_ = 207u,
|
||||
_Alignas_ = 208u,
|
||||
_Alignof_ = 209u,
|
||||
_Atomic_ = 210u,
|
||||
_Bool_ = 211u,
|
||||
_Complex_ = 212u,
|
||||
_Generic_ = 213u,
|
||||
_Imaginary_ = 214u,
|
||||
_Noreturn_ = 215u,
|
||||
_Static_assert_ = 216u,
|
||||
_Thread_local_ = 217u,
|
||||
_assert_ = 218u,
|
||||
_import_ = 219u,
|
||||
__cdecl_ = 220u,
|
||||
__declspec_ = 221u,
|
||||
__stdcall_ = 222u,
|
||||
__thread_ = 223u,
|
||||
__pragma_ = 224u,
|
||||
__int128_ = 225u,
|
||||
__attribute___ = 226u,
|
||||
variable = 18u,
|
||||
slice = 19u,
|
||||
version_ = 20u,
|
||||
module_ = 21u,
|
||||
dollar = 22u,
|
||||
template_ = 23u,
|
||||
typeof_ = 24u,
|
||||
pragma_ = 25u,
|
||||
typeid_ = 26u,
|
||||
comment = 27u,
|
||||
lessThan = 28u,
|
||||
greaterThan = 29u,
|
||||
lessOrEqual = 30u,
|
||||
greaterOrEqual = 31u,
|
||||
equal = 32u,
|
||||
notEqual = 33u,
|
||||
identity = 34u,
|
||||
notIdentity = 35u,
|
||||
is_ = 36u,
|
||||
leftShift = 37u,
|
||||
rightShift = 38u,
|
||||
leftShiftAssign = 39u,
|
||||
rightShiftAssign = 40u,
|
||||
unsignedRightShift = 41u,
|
||||
unsignedRightShiftAssign = 42u,
|
||||
concatenateAssign = 43u,
|
||||
add = 44u,
|
||||
min = 45u,
|
||||
addAssign = 46u,
|
||||
minAssign = 47u,
|
||||
mul = 48u,
|
||||
div = 49u,
|
||||
mod = 50u,
|
||||
mulAssign = 51u,
|
||||
divAssign = 52u,
|
||||
modAssign = 53u,
|
||||
and_ = 54u,
|
||||
or_ = 55u,
|
||||
xor_ = 56u,
|
||||
andAssign = 57u,
|
||||
orAssign = 58u,
|
||||
xorAssign = 59u,
|
||||
assign = 60u,
|
||||
not_ = 61u,
|
||||
tilde = 62u,
|
||||
plusPlus = 63u,
|
||||
minusMinus = 64u,
|
||||
dot = 65u,
|
||||
comma = 66u,
|
||||
question = 67u,
|
||||
andAnd = 68u,
|
||||
orOr = 69u,
|
||||
int32Literal = 70u,
|
||||
uns32Literal = 71u,
|
||||
int64Literal = 72u,
|
||||
uns64Literal = 73u,
|
||||
int128Literal = 74u,
|
||||
uns128Literal = 75u,
|
||||
float32Literal = 76u,
|
||||
float64Literal = 77u,
|
||||
float80Literal = 78u,
|
||||
imaginary32Literal = 79u,
|
||||
imaginary64Literal = 80u,
|
||||
imaginary80Literal = 81u,
|
||||
charLiteral = 82u,
|
||||
wcharLiteral = 83u,
|
||||
dcharLiteral = 84u,
|
||||
identifier = 85u,
|
||||
string_ = 86u,
|
||||
interpolated = 87u,
|
||||
hexadecimalString = 88u,
|
||||
this_ = 89u,
|
||||
super_ = 90u,
|
||||
error = 91u,
|
||||
void_ = 92u,
|
||||
int8 = 93u,
|
||||
uns8 = 94u,
|
||||
int16 = 95u,
|
||||
uns16 = 96u,
|
||||
int32 = 97u,
|
||||
uns32 = 98u,
|
||||
int64 = 99u,
|
||||
uns64 = 100u,
|
||||
int128 = 101u,
|
||||
uns128 = 102u,
|
||||
float32 = 103u,
|
||||
float64 = 104u,
|
||||
float80 = 105u,
|
||||
imaginary32 = 106u,
|
||||
imaginary64 = 107u,
|
||||
imaginary80 = 108u,
|
||||
complex32 = 109u,
|
||||
complex64 = 110u,
|
||||
complex80 = 111u,
|
||||
char_ = 112u,
|
||||
wchar_ = 113u,
|
||||
dchar_ = 114u,
|
||||
bool_ = 115u,
|
||||
struct_ = 116u,
|
||||
class_ = 117u,
|
||||
interface_ = 118u,
|
||||
union_ = 119u,
|
||||
enum_ = 120u,
|
||||
import_ = 121u,
|
||||
alias_ = 122u,
|
||||
override_ = 123u,
|
||||
delegate_ = 124u,
|
||||
function_ = 125u,
|
||||
mixin_ = 126u,
|
||||
align_ = 127u,
|
||||
extern_ = 128u,
|
||||
private_ = 129u,
|
||||
protected_ = 130u,
|
||||
public_ = 131u,
|
||||
export_ = 132u,
|
||||
static_ = 133u,
|
||||
final_ = 134u,
|
||||
const_ = 135u,
|
||||
abstract_ = 136u,
|
||||
debug_ = 137u,
|
||||
deprecated_ = 138u,
|
||||
in_ = 139u,
|
||||
out_ = 140u,
|
||||
inout_ = 141u,
|
||||
lazy_ = 142u,
|
||||
auto_ = 143u,
|
||||
package_ = 144u,
|
||||
immutable_ = 145u,
|
||||
if_ = 146u,
|
||||
else_ = 147u,
|
||||
while_ = 148u,
|
||||
for_ = 149u,
|
||||
do_ = 150u,
|
||||
switch_ = 151u,
|
||||
case_ = 152u,
|
||||
default_ = 153u,
|
||||
break_ = 154u,
|
||||
continue_ = 155u,
|
||||
with_ = 156u,
|
||||
synchronized_ = 157u,
|
||||
return_ = 158u,
|
||||
goto_ = 159u,
|
||||
try_ = 160u,
|
||||
catch_ = 161u,
|
||||
finally_ = 162u,
|
||||
asm_ = 163u,
|
||||
foreach_ = 164u,
|
||||
foreach_reverse_ = 165u,
|
||||
scope_ = 166u,
|
||||
onScopeExit = 167u,
|
||||
onScopeFailure = 168u,
|
||||
onScopeSuccess = 169u,
|
||||
invariant_ = 170u,
|
||||
unittest_ = 171u,
|
||||
argumentTypes = 172u,
|
||||
ref_ = 173u,
|
||||
macro_ = 174u,
|
||||
parameters = 175u,
|
||||
traits = 176u,
|
||||
pure_ = 177u,
|
||||
nothrow_ = 178u,
|
||||
gshared = 179u,
|
||||
line = 180u,
|
||||
file = 181u,
|
||||
fileFullPath = 182u,
|
||||
moduleString = 183u,
|
||||
functionString = 184u,
|
||||
prettyFunction = 185u,
|
||||
shared_ = 186u,
|
||||
at = 187u,
|
||||
pow = 188u,
|
||||
powAssign = 189u,
|
||||
goesTo = 190u,
|
||||
vector = 191u,
|
||||
pound = 192u,
|
||||
arrow = 193u,
|
||||
colonColon = 194u,
|
||||
wchar_tLiteral = 195u,
|
||||
endOfLine = 196u,
|
||||
whitespace = 197u,
|
||||
rvalue = 198u,
|
||||
inline_ = 199u,
|
||||
register_ = 200u,
|
||||
restrict_ = 201u,
|
||||
signed_ = 202u,
|
||||
sizeof_ = 203u,
|
||||
typedef_ = 204u,
|
||||
unsigned_ = 205u,
|
||||
volatile_ = 206u,
|
||||
_Alignas_ = 207u,
|
||||
_Alignof_ = 208u,
|
||||
_Atomic_ = 209u,
|
||||
_Bool_ = 210u,
|
||||
_Complex_ = 211u,
|
||||
_Generic_ = 212u,
|
||||
_Imaginary_ = 213u,
|
||||
_Noreturn_ = 214u,
|
||||
_Static_assert_ = 215u,
|
||||
_Thread_local_ = 216u,
|
||||
_assert_ = 217u,
|
||||
_import_ = 218u,
|
||||
__cdecl_ = 219u,
|
||||
__declspec_ = 220u,
|
||||
__stdcall_ = 221u,
|
||||
__thread_ = 222u,
|
||||
__pragma_ = 223u,
|
||||
__int128_ = 224u,
|
||||
__attribute___ = 225u,
|
||||
};
|
||||
|
||||
class FuncExp final : public Expression
|
||||
|
|
|
@ -5819,7 +5819,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
case TOK.plusPlus:
|
||||
case TOK.minusMinus:
|
||||
case TOK.new_:
|
||||
case TOK.delete_:
|
||||
case TOK.delegate_:
|
||||
case TOK.function_:
|
||||
case TOK.typeid_:
|
||||
|
@ -8688,15 +8687,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
e = new AST.ComExp(loc, e);
|
||||
break;
|
||||
|
||||
case TOK.delete_:
|
||||
// @@@DEPRECATED_2.109@@@
|
||||
// Use of `delete` keyword has been an error since 2.099.
|
||||
// Remove from the parser after 2.109.
|
||||
nextToken();
|
||||
e = parseUnaryExp();
|
||||
e = new AST.DeleteExp(loc, e, false);
|
||||
break;
|
||||
|
||||
case TOK.cast_: // cast(type) expression
|
||||
{
|
||||
nextToken();
|
||||
|
@ -8814,7 +8804,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
case TOK.dot:
|
||||
case TOK.plusPlus:
|
||||
case TOK.minusMinus:
|
||||
case TOK.delete_:
|
||||
case TOK.new_:
|
||||
case TOK.leftParenthesis:
|
||||
case TOK.identifier:
|
||||
|
|
|
@ -48,7 +48,6 @@ enum TOK : ubyte
|
|||
false_,
|
||||
throw_,
|
||||
new_,
|
||||
delete_,
|
||||
variable,
|
||||
slice,
|
||||
version_,
|
||||
|
@ -459,7 +458,6 @@ private immutable TOK[] keywords =
|
|||
TOK.false_,
|
||||
TOK.cast_,
|
||||
TOK.new_,
|
||||
TOK.delete_,
|
||||
TOK.throw_,
|
||||
TOK.module_,
|
||||
TOK.pragma_,
|
||||
|
@ -680,7 +678,6 @@ extern (C++) struct Token
|
|||
TOK.false_: "false",
|
||||
TOK.cast_: "cast",
|
||||
TOK.new_: "new",
|
||||
TOK.delete_: "delete",
|
||||
TOK.throw_: "throw",
|
||||
TOK.module_: "module",
|
||||
TOK.pragma_: "pragma",
|
||||
|
|
|
@ -54,7 +54,6 @@ enum class TOK : unsigned char
|
|||
false_,
|
||||
throw_,
|
||||
new_,
|
||||
delete_,
|
||||
variable,
|
||||
slice,
|
||||
version_,
|
||||
|
|
|
@ -36,9 +36,6 @@ void foo_compiles() {}
|
|||
static assert(!__traits(compiles, new Struct()));
|
||||
static assert(!__traits(compiles, new Object()));
|
||||
|
||||
int* p;
|
||||
static assert(!__traits(compiles, delete p));
|
||||
|
||||
int[int] aa;
|
||||
static assert( __traits(compiles, aa[0]));
|
||||
static assert(!__traits(compiles, (aa[0] = 10)));
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
// REQUIRED_ARGS: -o-
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail14486.d(47): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(47): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(48): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(48): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(53): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(53): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(54): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(54): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(59): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(59): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(60): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(60): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(65): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(65): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(66): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(66): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(71): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(71): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(72): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(72): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(77): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(77): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/fail14486.d(78): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail14486.d(78): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
|
||||
class C0a { }
|
||||
class C1a { ~this() {} }
|
||||
|
||||
class C0b { }
|
||||
class C1b { ~this() {} }
|
||||
|
||||
struct S0a { }
|
||||
struct S1a { ~this() {} }
|
||||
|
||||
struct S0b { }
|
||||
struct S1b { ~this() {} }
|
||||
|
||||
void test1a() @nogc pure @safe
|
||||
{
|
||||
C0a c0; delete c0; // error
|
||||
C1a c1; delete c1; // error
|
||||
}
|
||||
|
||||
void test1b() nothrow
|
||||
{
|
||||
C0b c0; delete c0; // no error
|
||||
C1b c1; delete c1; // error
|
||||
}
|
||||
|
||||
void test2a() @nogc pure @safe
|
||||
{
|
||||
S0a* s0; delete s0; // error
|
||||
S1a* s1; delete s1; // error
|
||||
}
|
||||
|
||||
void test2b() nothrow
|
||||
{
|
||||
S0b* s0; delete s0; // no error
|
||||
S1b* s1; delete s1; // error
|
||||
}
|
||||
|
||||
void test3a() @nogc pure @safe
|
||||
{
|
||||
S0a[] a0; delete a0; // error
|
||||
S1a[] a1; delete a1; // error
|
||||
}
|
||||
|
||||
void test3b() nothrow
|
||||
{
|
||||
S0b[] a0; delete a0; // no error
|
||||
S1b[] a1; delete a1; // error
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// REQUIRED_ARGS: -de
|
||||
/* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail17906.d(12): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail17906.d(12): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=18647
|
||||
deprecated void main ()
|
||||
{
|
||||
Object o = new Object;
|
||||
delete o;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail2361.d(14): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail2361.d(14): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
|
||||
class C {}
|
||||
|
||||
void main()
|
||||
{
|
||||
immutable c = new immutable(C);
|
||||
delete c;
|
||||
}
|
|
@ -209,8 +209,6 @@ 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: cannot take address of expression `([1] * 6)[0..2]` because it is not an lvalue
|
||||
fail_compilation/fail_arrayop2.d(278): Error: can only `*` a pointer, not a `int[]`
|
||||
fail_compilation/fail_arrayop2.d(281): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/fail_arrayop2.d(281): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
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
|
||||
fail_compilation/fail_arrayop2.d(290): Error: cannot modify expression `[1] * 6` because it is not an lvalue
|
||||
|
@ -235,6 +233,8 @@ fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without
|
|||
fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed
|
||||
---
|
||||
*/
|
||||
|
||||
|
||||
// Test all expressions, which can take arrays as their operands but cannot be a part of array operation.
|
||||
void test15407exp()
|
||||
{
|
||||
|
@ -277,8 +277,8 @@ void test15407exp()
|
|||
// PtrExp, *([1] * 6).ptr is also invalid -> show better diagnostic
|
||||
{ auto r = *([1] * 6); }
|
||||
|
||||
// DeleteExp - e1
|
||||
delete ([1] * 6);
|
||||
|
||||
|
||||
|
||||
// TypeDArray.dotExp, cannot check in ArrayLengthExp.semantic()
|
||||
{ auto r = (6 * da[]).length; }
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/faildeleteaa.d(12): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/faildeleteaa.d(12): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
|
||||
void main()
|
||||
{
|
||||
int[int] aa = [1 : 2];
|
||||
delete aa[1];
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
----
|
||||
fail_compilation/ice11968.d(9): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/ice11968.d(9): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
----
|
||||
*/
|
||||
|
||||
void main() { delete __FILE__ ; }
|
|
@ -57,23 +57,3 @@ fail_compilation/nogc1.d(55): Error: allocating with `new` causes a GC allocatio
|
|||
scope Object o1 = new Object(); // no error
|
||||
scope o2 = new Object(); // no error
|
||||
}
|
||||
|
||||
/***************** DeleteExp *******************/
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/nogc1.d(76): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/nogc1.d(76): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/nogc1.d(77): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/nogc1.d(77): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
fail_compilation/nogc1.d(78): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/nogc1.d(78): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
@nogc void testDelete(int* p, Object o, S1* s)
|
||||
{
|
||||
delete p;
|
||||
delete o;
|
||||
delete s;
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/test16195.d(14): Error: the `delete` keyword is obsolete
|
||||
fail_compilation/test16195.d(14): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
|
||||
---
|
||||
*/
|
||||
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=16195
|
||||
|
||||
@safe pure nothrow @nogc void test(int* p)
|
||||
{
|
||||
delete p;
|
||||
}
|
|
@ -383,16 +383,6 @@ void test6714()
|
|||
assert(bar6714y((a, b){ return a; }) == 2);
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=7193
|
||||
|
||||
void test7193()
|
||||
{
|
||||
static assert(!__traits(compiles, {
|
||||
delete a => a;
|
||||
}));
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=7207
|
||||
// on CastExp
|
||||
|
@ -1331,7 +1321,6 @@ int main()
|
|||
test11();
|
||||
test3235();
|
||||
test6714();
|
||||
test7193();
|
||||
test7202();
|
||||
test7288();
|
||||
test7499();
|
||||
|
|
|
@ -41,11 +41,30 @@ void test1()
|
|||
assert(Foo.flags == 1);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
// delete is no longer a keyword and can be used as an identifier
|
||||
|
||||
enum E
|
||||
{
|
||||
add, delete
|
||||
}
|
||||
|
||||
E delete()
|
||||
{
|
||||
return E.delete;
|
||||
}
|
||||
|
||||
void test2()
|
||||
{
|
||||
assert(delete() == E.delete);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
|
||||
printf("Success\n");
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue