Skip to content

Commit

Permalink
Merge pull request #8519 from JinShil/fix_19107
Browse files Browse the repository at this point in the history
Fix Issue 19107 - -de produces compilation error, -dw does not
  • Loading branch information
wilzbach authored Jul 31, 2018
2 parents 17ecf09 + c72fc35 commit 03e7693
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/dmd/errors.d
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,18 @@ extern (C++) void verrorSupplemental(const ref Loc loc, const(char)* format, va_
*/
extern (C++) void vwarning(const ref Loc loc, const(char)* format, va_list ap)
{
if (global.params.warnings && !global.gag)
if (global.params.warnings)
{
verrorPrint(loc, Classification.warning, "Warning: ", format, ap);
//halt();
if (global.params.warnings == 1)
global.warnings++; // warnings don't count if gagged
if (!global.gag)
{
verrorPrint(loc, Classification.warning, "Warning: ", format, ap);
if (global.params.warnings == 1)
global.warnings++;
}
else
{
global.gaggedWarnings++;
}
}
}

Expand Down Expand Up @@ -335,8 +341,17 @@ extern (C++) void vdeprecation(const ref Loc loc, const(char)* format, va_list a
static __gshared const(char)* header = "Deprecation: ";
if (global.params.useDeprecated == 0)
verror(loc, format, ap, p1, p2, header);
else if (global.params.useDeprecated == 2 && !global.gag)
verrorPrint(loc, Classification.deprecation, header, format, ap, p1, p2);
else if (global.params.useDeprecated == 2)
{
if (!global.gag)
{
verrorPrint(loc, Classification.deprecation, header, format, ap, p1, p2);
}
else
{
global.gaggedWarnings++;
}
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/dmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ struct Global
uint warnings; // number of warnings reported so far
uint gag; // !=0 means gag reporting of errors & warnings
uint gaggedErrors; // number of errors reported while gagged
uint gaggedWarnings; // number of warnings reported while gagged

void* console; // opaque pointer to console for controlling text attributes

Expand All @@ -275,6 +276,7 @@ struct Global
extern (C++) uint startGagging()
{
++gag;
gaggedWarnings = 0;
return gaggedErrors;
}

Expand Down
12 changes: 12 additions & 0 deletions src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -909,12 +909,24 @@ extern (C++) abstract class Type : RootObject
final Type trySemantic(const ref Loc loc, Scope* sc)
{
//printf("+trySemantic(%s) %d\n", toChars(), global.errors);

// Needed to display any deprecations that were gagged
auto tcopy = this.syntaxCopy();

uint errors = global.startGagging();
Type t = typeSemantic(this, loc, sc);
if (global.endGagging(errors) || t.ty == Terror) // if any errors happened
{
t = null;
}
else
{
// If `typeSemantic` succeeded, there may have been deprecations that
// were gagged due the the `startGagging` above. Run again to display
// those deprecations. https://issues.dlang.org/show_bug.cgi?id=19107
if (global.gaggedWarnings > 0)
typeSemantic(tcopy, loc, sc);
}
//printf("-trySemantic(%s) %d\n", toChars(), global.errors);
return t;
}
Expand Down
3 changes: 3 additions & 0 deletions test/compilable/imports/test19107a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module imports.test19107a.d;

alias I(alias A) = A;
3 changes: 3 additions & 0 deletions test/compilable/imports/test19107b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module imports.test19107b;

import imports.test19107a : I;
20 changes: 20 additions & 0 deletions test/compilable/test19107.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// REQUIRED_ARGS: -dw
/*
TEST_OUTPUT:
---
compilable/test19107.d(14): Deprecation: `imports.test19107b.I` is not visible from module `test19107`
---
*/

// https://issues.dlang.org/show_bug.cgi?id=19107

import imports.test19107b;

void all(alias pred, T)(T t)
if (is(typeof(I!pred(t))))
{ }

void main(string[] args)
{
args.all!(c => c);
}

0 comments on commit 03e7693

Please sign in to comment.