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
5 changes: 5 additions & 0 deletions src/dmd/denum.d
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ extern (C++) final class EnumMember : VarDeclaration
if (errors)
return new ErrorExp();
checkDisabled(loc, sc);

if (depdecl && !depdecl._scope)
depdecl._scope = sc;
Copy link
Member

@PetarKirov PetarKirov Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a little while to see that DeprecatedDeclaration._scope is used here:

dmd/src/dmd/dsymbolsem.d

Lines 410 to 428 in 58fde67

const(char)* getMessage(DeprecatedDeclaration dd)
{
if (auto sc = dd._scope)
{
dd._scope = null;
sc = sc.startCTFE();
dd.msg = dd.msg.expressionSemantic(sc);
dd.msg = resolveProperties(sc, dd.msg);
sc = sc.endCTFE();
dd.msg = dd.msg.ctfeInterpret();
if (auto se = dd.msg.toStringExp())
dd.msgstr = se.toStringz().ptr;
else
dd.msg.error("compile time constant expected, not `%s`", dd.msg.toChars());
}
return dd.msgstr;
}

which is called from here:

dmd/src/dmd/dsymbol.d

Lines 300 to 324 in ce5e177

final bool checkDeprecated(const ref Loc loc, Scope* sc)
{
if (global.params.useDeprecated != 1 && isDeprecated())
{
// Don't complain if we're inside a deprecated symbol's scope
if (sc.isDeprecated())
return false;
const(char)* message = null;
for (Dsymbol p = this; p; p = p.parent)
{
message = p.depdecl ? p.depdecl.getMessage() : null;
if (message)
break;
}
if (message)
deprecation(loc, "is deprecated - %s", message);
else
deprecation(loc, "is deprecated");
return true;
}
return false;
}

checkDeprecated(loc, sc);

if (errors)
return new ErrorExp();
Expression e = new VarExp(loc, this);
Expand Down
7 changes: 0 additions & 7 deletions src/dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -3347,11 +3347,6 @@ extern (C++) final class SymOffExp : SymbolExp
*/
extern (C++) final class VarExp : SymbolExp
{
/**
* Semantic can be called multiple times for a single expression.
* This field is needed to ensure the deprecation message will be printed only once.
*/
bool hasCheckedAttrs;
extern (D) this(const ref Loc loc, Declaration var, bool hasOverloads = true)
{
if (var.isVarDeclaration())
Expand All @@ -3361,7 +3356,6 @@ extern (C++) final class VarExp : SymbolExp
//printf("VarExp(this = %p, '%s', loc = %s)\n", this, var.toChars(), loc.toChars());
//if (strcmp(var.ident.toChars(), "func") == 0) assert(0);
this.type = var.type;
this.hasCheckedAttrs = false;
}

static VarExp create(Loc loc, Declaration var, bool hasOverloads = true)
Expand Down Expand Up @@ -3445,7 +3439,6 @@ extern (C++) final class VarExp : SymbolExp
override Expression syntaxCopy()
{
auto ret = super.syntaxCopy();
(cast(VarExp)ret).hasCheckedAttrs = this.hasCheckedAttrs;
return ret;
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3454,16 +3454,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
* variables as alias template parameters.
*/
//checkAccess(loc, sc, NULL, var);
if (!e.hasCheckedAttrs && e.var.isEnumMember())
{
e.hasCheckedAttrs = true;
if (e.var.depdecl && !e.var.depdecl._scope)
{
e.var.depdecl._scope = sc;
}
e.checkDeprecated(sc, e.var);

}

if (auto vd = e.var.isVarDeclaration())
{
Expand Down