Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}