mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
Remove debug() / version() integers (#20713)
This commit is contained in:
parent
c0315897f6
commit
888917669c
7 changed files with 19 additions and 95 deletions
4
changelog/dmd.deprecation-version-debug-number.dd
Normal file
4
changelog/dmd.deprecation-version-debug-number.dd
Normal file
|
@ -0,0 +1,4 @@
|
|||
Integers in debug or version statements have been removed from the language
|
||||
|
||||
These were deprecated in 2.101.
|
||||
Use `-debug=identifier` and `-version=identifier` instead for versions set on the command line, or `version = identifier;` and `debug = identifier;` for versions set in code at global scope.
|
|
@ -1591,20 +1591,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param
|
|||
{
|
||||
// Parse:
|
||||
// -debug
|
||||
// -debug=number
|
||||
// -debug=identifier
|
||||
if (p[6] == '=')
|
||||
{
|
||||
if (isdigit(cast(char)p[7]))
|
||||
{
|
||||
if (!params.debuglevel.parseDigits(p.toDString()[7 .. $]))
|
||||
goto Lerror;
|
||||
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
eSink.deprecation(Loc.initial, "`-debug=number` is deprecated, use debug identifiers instead");
|
||||
}
|
||||
else if (Identifier.isValidIdentifier(p + 7))
|
||||
if (Identifier.isValidIdentifier(p + 7))
|
||||
{
|
||||
DebugCondition.addGlobalIdent((p + 7).toDString());
|
||||
}
|
||||
|
@ -1619,20 +1609,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param
|
|||
else if (startsWith(p + 1, "version")) // https://dlang.org/dmd.html#switch-version
|
||||
{
|
||||
// Parse:
|
||||
// -version=number
|
||||
// -version=identifier
|
||||
if (p[8] == '=')
|
||||
{
|
||||
if (isdigit(cast(char)p[9]))
|
||||
{
|
||||
if (!params.versionlevel.parseDigits(p.toDString()[9 .. $]))
|
||||
goto Lerror;
|
||||
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
eSink.deprecation(Loc.initial, "`-version=number` is deprecated, use version identifiers instead");
|
||||
}
|
||||
else if (Identifier.isValidIdentifier(p + 9))
|
||||
if (Identifier.isValidIdentifier(p + 9))
|
||||
{
|
||||
VersionCondition.addGlobalIdent((p+9).toDString());
|
||||
}
|
||||
|
|
|
@ -2257,17 +2257,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
nextToken();
|
||||
if (token.value == TOK.identifier)
|
||||
s = new AST.DebugSymbol(token.loc, token.ident);
|
||||
else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal)
|
||||
{
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
deprecation("`debug = <integer>` is deprecated, use debug identifiers instead");
|
||||
|
||||
s = new AST.DebugSymbol(token.loc, cast(uint)token.unsvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("identifier or integer expected, not `%s`", token.toChars());
|
||||
error("identifier expected, not `%s`", token.toChars());
|
||||
s = null;
|
||||
}
|
||||
nextToken();
|
||||
|
@ -2292,16 +2284,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
|
||||
if (token.value == TOK.identifier)
|
||||
id = token.ident;
|
||||
else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal)
|
||||
{
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
deprecation("`debug( <integer> )` is deprecated, use debug identifiers instead");
|
||||
|
||||
level = cast(uint)token.unsvalue;
|
||||
}
|
||||
else
|
||||
error("identifier or integer expected inside `debug(...)`, not `%s`", token.toChars());
|
||||
error("identifier expected inside `debug(...)`, not `%s`", token.toChars());
|
||||
loc = token.loc;
|
||||
nextToken();
|
||||
check(TOK.rightParenthesis);
|
||||
|
@ -2318,16 +2302,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
nextToken();
|
||||
if (token.value == TOK.identifier)
|
||||
s = new AST.VersionSymbol(token.loc, token.ident);
|
||||
else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal)
|
||||
{
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
deprecation("`version = <integer>` is deprecated, use version identifiers instead");
|
||||
s = new AST.VersionSymbol(token.loc, cast(uint)token.unsvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("identifier or integer expected, not `%s`", token.toChars());
|
||||
error("identifier expected, not `%s`", token.toChars());
|
||||
s = null;
|
||||
}
|
||||
nextToken();
|
||||
|
@ -2357,20 +2334,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
loc = token.loc;
|
||||
if (token.value == TOK.identifier)
|
||||
id = token.ident;
|
||||
else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal)
|
||||
{
|
||||
// @@@DEPRECATED_2.111@@@
|
||||
// Deprecated in 2.101, remove in 2.111
|
||||
deprecation("`version( <integer> )` is deprecated, use version identifiers instead");
|
||||
|
||||
level = cast(uint)token.unsvalue;
|
||||
}
|
||||
else if (token.value == TOK.unittest_)
|
||||
id = Identifier.idPool(Token.toString(TOK.unittest_));
|
||||
else if (token.value == TOK.assert_)
|
||||
id = Identifier.idPool(Token.toString(TOK.assert_));
|
||||
else
|
||||
error("identifier or integer expected inside `version(...)`, not `%s`", token.toChars());
|
||||
error("identifier expected inside `version(...)`, not `%s`", token.toChars());
|
||||
nextToken();
|
||||
check(TOK.rightParenthesis);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/diag11198.d(17): Error: version `blah` declaration must be at module level
|
||||
fail_compilation/diag11198.d(18): Error: debug `blah` declaration must be at module level
|
||||
fail_compilation/diag11198.d(19): Deprecation: `version = <integer>` is deprecated, use version identifiers instead
|
||||
fail_compilation/diag11198.d(19): Error: version `1` level declaration must be at module level
|
||||
fail_compilation/diag11198.d(20): Deprecation: `debug = <integer>` is deprecated, use debug identifiers instead
|
||||
fail_compilation/diag11198.d(20): Error: debug `2` level declaration must be at module level
|
||||
fail_compilation/diag11198.d(21): Error: identifier or integer expected, not `""`
|
||||
fail_compilation/diag11198.d(22): Error: identifier or integer expected, not `""`
|
||||
fail_compilation/diag11198.d(13): Error: version `blah` declaration must be at module level
|
||||
fail_compilation/diag11198.d(14): Error: debug `blah` declaration must be at module level
|
||||
fail_compilation/diag11198.d(15): Error: identifier expected, not `""`
|
||||
fail_compilation/diag11198.d(16): Error: identifier expected, not `""`
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -16,8 +12,6 @@ void main()
|
|||
{
|
||||
version = blah;
|
||||
debug = blah;
|
||||
version = 1;
|
||||
debug = 2;
|
||||
version = "";
|
||||
debug = "";
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/diag_debug_conditional.d(1): Error: identifier or integer expected inside `debug(...)`, not `alias`
|
||||
fail_compilation/diag_debug_conditional.d(2): Error: identifier or integer expected inside `version(...)`, not `alias`
|
||||
fail_compilation/diag_debug_conditional.d(1): Error: identifier expected inside `debug(...)`, not `alias`
|
||||
fail_compilation/diag_debug_conditional.d(2): Error: identifier expected inside `version(...)`, not `alias`
|
||||
fail_compilation/diag_debug_conditional.d(3): Error: declaration expected following attribute, not end of file
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/test13786.d(16): Deprecation: `debug = <integer>` is deprecated, use debug identifiers instead
|
||||
fail_compilation/test13786.d(18): Deprecation: `version = <integer>` is deprecated, use version identifiers instead
|
||||
fail_compilation/test13786.d(16): Error: debug `123` level declaration must be at module level
|
||||
fail_compilation/test13786.d(17): Error: debug `abc` declaration must be at module level
|
||||
fail_compilation/test13786.d(18): Error: version `123` level declaration must be at module level
|
||||
fail_compilation/test13786.d(19): Error: version `abc` declaration must be at module level
|
||||
fail_compilation/test13786.d(22): Error: template instance `test13786.T!()` error instantiating
|
||||
fail_compilation/test13786.d(12): Error: debug `abc` declaration must be at module level
|
||||
fail_compilation/test13786.d(13): Error: version `abc` declaration must be at module level
|
||||
fail_compilation/test13786.d(16): Error: template instance `test13786.T!()` error instantiating
|
||||
---
|
||||
*/
|
||||
|
||||
template T()
|
||||
{
|
||||
debug = 123;
|
||||
debug = abc;
|
||||
version = 123;
|
||||
version = abc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
// REQUIRED_ARGS: -verrors=simple
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
runnable/lexer.d(86): Deprecation: `version( <integer> )` is deprecated, use version identifiers instead
|
||||
runnable/lexer.d(87): Deprecation: `debug( <integer> )` is deprecated, use debug identifiers instead
|
||||
---
|
||||
*/
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
void test6()
|
||||
{
|
||||
string s = q"(foo(xxx))";
|
||||
|
@ -82,12 +71,6 @@ void test8()
|
|||
|
||||
/*********************************************************/
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=6584
|
||||
version(9223372036854775807){}
|
||||
debug(9223372036854775807){}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
enum e13102=184467440737095516153.6L;
|
||||
|
||||
/*********************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue