Skip to content

Commit

Permalink
Merge pull request #3916 from yebblies/issue2656
Browse files Browse the repository at this point in the history
Issue 2656 - Remove octal literals
  • Loading branch information
9rnsr committed Aug 31, 2014
2 parents 8d7b4d1 + 2457435 commit c50c52d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ TOK Lexer::number(Token *t)
}

if (base == 8 && n >= 8)
deprecation("octal literals 0%llo%.*s are deprecated, use std.conv.octal!%llo%.*s instead",
error("octal literals 0%llo%.*s are no longer supported, use std.conv.octal!%llo%.*s instead",
n, p - psuffix, psuffix, n, p - psuffix, psuffix);

TOK result;
Expand Down
34 changes: 34 additions & 0 deletions test/fail_compilation/fail2656.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail2656.d(21): Error: octal literals 0123 are no longer supported, use std.conv.octal!123 instead
fail_compilation/fail2656.d(22): Error: octal literals 01000000000000000000000 are no longer supported, use std.conv.octal!1000000000000000000000 instead
fail_compilation/fail2656.d(23): Error: octal literals 0100000L are no longer supported, use std.conv.octal!100000L instead
fail_compilation/fail2656.d(24): Error: octal literals 01777777777777777777777u are no longer supported, use std.conv.octal!1777777777777777777777u instead
fail_compilation/fail2656.d(25): Error: octal literals 017777777777uL are no longer supported, use std.conv.octal!17777777777uL instead
fail_compilation/fail2656.d(26): Error: octal literals 0177777 are no longer supported, use std.conv.octal!177777 instead
fail_compilation/fail2656.d(27): Error: octal literals 020000000000L are no longer supported, use std.conv.octal!20000000000L instead
fail_compilation/fail2656.d(28): Error: octal literals 0200000u are no longer supported, use std.conv.octal!200000u instead
fail_compilation/fail2656.d(29): Error: octal literals 037777777777uL are no longer supported, use std.conv.octal!37777777777uL instead
fail_compilation/fail2656.d(30): Error: octal literals 040000000000 are no longer supported, use std.conv.octal!40000000000 instead
fail_compilation/fail2656.d(31): Error: octal literals 0777777777777777777777L are no longer supported, use std.conv.octal!777777777777777777777L instead
fail_compilation/fail2656.d(32): Error: octal literals 077777u are no longer supported, use std.conv.octal!77777u instead
fail_compilation/fail2656.d(33): Error: octal literals 077777uL are no longer supported, use std.conv.octal!77777uL instead
fail_compilation/fail2656.d(34): Error: octal literals 077777uL are no longer supported, use std.conv.octal!77777uL instead
---
*/

auto a = 0123;
auto b = 01000000000000000000000;
auto c = 0100000L;
auto d = 01777777777777777777777u;
auto e = 017777777777uL;
auto f = 0177777;
auto g = 020000000000L;
auto h = 0200000u;
auto i = 037777777777uL;
auto j = 040000000000;
auto k = 0777777777777777777777L;
auto l = 077777u;
auto m = 077777uL;
auto n = 0_7_7_7_7_7uL;
15 changes: 0 additions & 15 deletions test/runnable/deprecate1.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ void foo6e() {
}


/**************************************
octal literals
**************************************/

void test10()
{
int b = 0b_1_1__1_0_0_0_1_0_1_0_1_0_;
assert(b == 3626);

b = 0_1_2_3_4_;
printf("b = %d\n", b);
assert(b == 668);
}

/**************************************
typedef
**************************************/
Expand Down Expand Up @@ -1245,7 +1231,6 @@ int main()
{
test2();
test5();
test10();
test19();
test33();
test41();
Expand Down
54 changes: 0 additions & 54 deletions test/runnable/literal.d
Original file line number Diff line number Diff line change
Expand Up @@ -104,60 +104,6 @@ void test1()
assert(dotype(0x8000000000000000uL) == T_ulong);
assert(dotype(0xFFFFFFFFFFFFFFFFuL) == T_ulong);

/***************** Octal ***********************/

assert(dotype(0) == T_int);
assert(dotype(077777) == T_int);
assert(dotype(0100000) == T_int);
assert(dotype(0177777) == T_int);
assert(dotype(0200000) == T_int);
assert(dotype(017777777777) == T_int);
assert(dotype(020000000000) == T_uint);
assert(dotype(037777777777) == T_uint);
assert(dotype(040000000000) == T_long);
assert(dotype(0777777777777777777777) == T_long);
assert(dotype(01000000000000000000000) == T_ulong);
assert(dotype(01777777777777777777777) == T_ulong);

assert(dotype(0u) == T_uint);
assert(dotype(077777u) == T_uint);
assert(dotype(0100000u) == T_uint);
assert(dotype(0177777u) == T_uint);
assert(dotype(0200000u) == T_uint);
assert(dotype(017777777777u) == T_uint);
assert(dotype(020000000000u) == T_uint);
assert(dotype(037777777777u) == T_uint);
assert(dotype(040000000000u) == T_ulong);
assert(dotype(0777777777777777777777u) == T_ulong);
assert(dotype(01000000000000000000000u) == T_ulong);
assert(dotype(01777777777777777777777u) == T_ulong);

assert(dotype(0L) == T_long);
assert(dotype(077777L) == T_long);
assert(dotype(0100000L) == T_long);
assert(dotype(0177777L) == T_long);
assert(dotype(0200000L) == T_long);
assert(dotype(017777777777L) == T_long);
assert(dotype(020000000000L) == T_long);
assert(dotype(037777777777L) == T_long);
assert(dotype(040000000000L) == T_long);
assert(dotype(0777777777777777777777L) == T_long);
assert(dotype(01000000000000000000000L) == T_ulong);
assert(dotype(01777777777777777777777L) == T_ulong);

assert(dotype(0uL) == T_ulong);
assert(dotype(077777uL) == T_ulong);
assert(dotype(0100000uL) == T_ulong);
assert(dotype(0177777uL) == T_ulong);
assert(dotype(0200000uL) == T_ulong);
assert(dotype(017777777777uL) == T_ulong);
assert(dotype(020000000000uL) == T_ulong);
assert(dotype(037777777777uL) == T_ulong);
assert(dotype(040000000000uL) == T_ulong);
assert(dotype(0777777777777777777777uL) == T_ulong);
assert(dotype(01000000000000000000000uL) == T_ulong);
assert(dotype(01777777777777777777777uL) == T_ulong);

/***************** Decimal ***********************/

assert(dotype(0) == T_int);
Expand Down

0 comments on commit c50c52d

Please sign in to comment.