Skip to content

Commit

Permalink
Merge pull request #6803 from WalterBright/denum-errors
Browse files Browse the repository at this point in the history
denum.d: enable syntax highlighting of error messages
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Jun 10, 2017
2 parents 10e086a + 5d36e96 commit f1ecc9d
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 89 deletions.
18 changes: 9 additions & 9 deletions src/ddmd/denum.d
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
if (semanticRun == PASSsemantic)
{
assert(memtype);
.error(loc, "circular reference to enum base type %s", memtype.toChars());
.error(loc, "circular reference to enum base type `%s`", memtype.toChars());
errors = true;
semanticRun = PASSsemanticdone;
return;
Expand Down Expand Up @@ -213,7 +213,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol

if (members.dim == 0)
{
error("enum %s must have at least one member", toChars());
error("enum `%s` must have at least one member", toChars());
errors = true;
return;
}
Expand Down Expand Up @@ -320,7 +320,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol

if (!members || !symtab || _scope)
{
error("is forward referenced when looking for '%s'", ident.toChars());
error("is forward referenced when looking for `%s`", ident.toChars());
//*(char*)0=0;
return null;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol

if (inuse)
{
error(loc, "recursive definition of .%s property", id.toChars());
error(loc, "recursive definition of `.%s` property", id.toChars());
return errorReturn();
}
if (*pval)
Expand All @@ -377,12 +377,12 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
return errorReturn();
if (semanticRun == PASSinit || !members)
{
error("is forward referenced looking for .%s", id.toChars());
error("is forward referenced looking for `.%s`", id.toChars());
return errorReturn();
}
if (!(memtype && memtype.isintegral()))
{
error(loc, "has no .%s property because base type %s is not an integral type", id.toChars(), memtype ? memtype.toChars() : "");
error(loc, "has no `.%s` property because base type `%s` is not an integral type", id.toChars(), memtype ? memtype.toChars() : "");
return errorReturn();
}

Expand Down Expand Up @@ -443,7 +443,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
goto Lerrors;
if (semanticRun == PASSinit || !members)
{
error(loc, "forward reference of %s.init", toChars());
error(loc, "forward reference of `%s.init`", toChars());
goto Lerrors;
}

Expand Down Expand Up @@ -723,7 +723,7 @@ extern (C++) final class EnumMember : VarDeclaration
e = e.ctfeInterpret();
if (e.toInteger())
{
error("initialization with (%s.%s + 1) causes overflow for type '%s'",
error("initialization with `%s.%s+1` causes overflow for type `%s`",
emprev.ed.toChars(), emprev.toChars(), ed.memtype.toChars());
return errorReturn();
}
Expand Down Expand Up @@ -753,7 +753,7 @@ extern (C++) final class EnumMember : VarDeclaration
etest = etest.ctfeInterpret();
if (etest.toInteger())
{
error("has inexact value, due to loss of precision");
error("has inexact value due to loss of precision");
return errorReturn();
}
}
Expand Down
18 changes: 0 additions & 18 deletions test/fail_compilation/diag11088.d

This file was deleted.

19 changes: 0 additions & 19 deletions test/fail_compilation/diag14950.d

This file was deleted.

81 changes: 80 additions & 1 deletion test/fail_compilation/fail109.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail109.d(12): Error: enum member fail109.Bool.Unknown initialization with (Bool.True + 1) causes overflow for type 'bool'
fail_compilation/fail109.d(12): Error: enum member fail109.Bool.Unknown initialization with `Bool.True+1` causes overflow for type `bool`
---
*/

Expand All @@ -11,3 +11,82 @@ enum Bool : bool
True,
Unknown
}

/* Bugzilla 11088
TEST_OUTPUT:
---
fail_compilation/fail109.d(25): Error: enum member fail109.E.B initialization with `E.A+1` causes overflow for type `int`
fail_compilation/fail109.d(31): Error: enum member fail109.E1.B initialization with `E1.A+1` causes overflow for type `short`
---
*/
enum E
{
A = int.max,
B
}

enum E1 : short
{
A = short.max,
B
}

/* Bugzilla 14950
TEST_OUTPUT:
---
fail_compilation/fail109.d(50): Deprecation: Comparison between different enumeration types `B` and `C`; If this behavior is intended consider using `std.conv.asOriginalType`
fail_compilation/fail109.d(50): Error: enum member fail109.B.end initialization with `B.start+1` causes overflow for type `C`
---
*/
enum C
{
start,
end
}

enum B
{
start = C.end,
end
}

/* Bugzilla 11849
TEST_OUTPUT:
---
fail_compilation/fail109.d(72): Error: enum fail109.RegValueType1a recursive definition of `.max` property
fail_compilation/fail109.d(79): Error: enum fail109.RegValueType1b recursive definition of `.max` property
fail_compilation/fail109.d(84): Error: enum fail109.RegValueType2a recursive definition of `.min` property
fail_compilation/fail109.d(91): Error: enum fail109.RegValueType2b recursive definition of `.min` property
---
*/

alias DWORD = uint;

enum : DWORD
{
REG_DWORD = 4
}

enum RegValueType1a : DWORD
{
Unknown = DWORD.max,
DWORD = REG_DWORD,
}

enum RegValueType1b : DWORD
{
DWORD = REG_DWORD,
Unknown = DWORD.max,
}

enum RegValueType2a : DWORD
{
Unknown = DWORD.min,
DWORD = REG_DWORD,
}

enum RegValueType2b : DWORD
{
DWORD = REG_DWORD,
Unknown = DWORD.min,
}
40 changes: 0 additions & 40 deletions test/fail_compilation/ice11849a.d

This file was deleted.

4 changes: 2 additions & 2 deletions test/fail_compilation/ice11849b.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice11849b.d(11): Error: circular reference to enum base type DWORD1
fail_compilation/ice11849b.d(11): Error: circular reference to enum base type `DWORD1`
fail_compilation/ice11849b.d(11): Error: DWORD1 is used as a type
fail_compilation/ice11849b.d(16): Error: circular reference to enum base type typeof(DWORD2)
fail_compilation/ice11849b.d(16): Error: circular reference to enum base type `typeof(DWORD2)`
---
*/
enum REG_DWORD = 1;
Expand Down

0 comments on commit f1ecc9d

Please sign in to comment.