Skip to content

Commit

Permalink
Merge pull request ldc-developers#3143 from kinke/merge-2.088
Browse files Browse the repository at this point in the history
Upgrade front-end & libs to v2.088.0
  • Loading branch information
kinke authored Sep 7, 2019
2 parents 2724c0d + 3e82f74 commit f3fe277
Show file tree
Hide file tree
Showing 102 changed files with 3,625 additions and 2,576 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ include(GetLinuxDistribution)
#

# Version information
set(LDC_VERSION "1.17.0") # May be overridden by git hash tag
set(LDC_VERSION "1.18.0") # May be overridden by git hash tag
set(DMDFE_MAJOR_VERSION 2)
set(DMDFE_MINOR_VERSION 0)
set(DMDFE_PATCH_VERSION 87)
set(DMDFE_FIX_LEVEL 1) # Comment out if not used
set(DMDFE_PATCH_VERSION 88)
set(DMDFE_FIX_LEVEL 0)

set(DMD_VERSION ${DMDFE_MAJOR_VERSION}.${DMDFE_MINOR_VERSION}${DMDFE_PATCH_VERSION})
if(DEFINED DMDFE_FIX_LEVEL)
Expand Down
35 changes: 22 additions & 13 deletions dmd/aggregate.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module dmd.aggregate;
import core.stdc.stdio;
import core.checkedint;

import dmd.aliasthis;
import dmd.arraytypes;
import dmd.gluelayer; // : Symbol;
import dmd.declaration;
Expand Down Expand Up @@ -108,7 +109,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
// it would be stored in TypeInfo_Class.defaultConstructor
CtorDeclaration defaultCtor;

Dsymbol aliasthis; // forward unresolved lookups to aliasthis
AliasThis aliasthis; // forward unresolved lookups to aliasthis
bool noDefaultCtor; // no default construction

DtorDeclarations dtors; // Array of destructors
Expand All @@ -132,10 +133,9 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
Scope* newScope(Scope* sc)
{
auto sc2 = sc.push(this);
sc2.stc &= STC.safe | STC.trusted | STC.system;
sc2.stc &= STC.safeGroup;
sc2.parent = this;
if (isUnionDeclaration())
sc2.inunion = true;
sc2.inunion = isUnionDeclaration();
sc2.protection = Prot(Prot.Kind.public_);
sc2.explicitProtection = 0;
sc2.aligndecl = null;
Expand Down Expand Up @@ -349,9 +349,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
continue;
}

auto vx = vd;
if (vd._init && vd._init.isVoidInitializer())
vx = null;
const vdIsVoidInit = vd._init && vd._init.isVoidInitializer();

// Find overlapped fields with the hole [vd.offset .. vd.offset.size()].
foreach (j; 0 .. nfields)
Expand All @@ -376,16 +374,27 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (!MODimplicitConv(v2.type.mod, vd.type.mod))
vd.overlapUnsafe = true;

if (!vx)
if (i > j)
continue;
if (v2._init && v2._init.isVoidInitializer())

if (!v2._init)
continue;

if (vx._init && v2._init)
if (v2._init.isVoidInitializer())
continue;

if (vd._init && !vdIsVoidInit && v2._init)
{
.error(loc, "overlapping default initialization for field `%s` and `%s`", v2.toChars(), vd.toChars());
errors = true;
}
else if (v2._init && i < j)
{
// @@@DEPRECATED_v2.086@@@.
.deprecation(v2.loc, "union field `%s` with default initialization `%s` must be before field `%s`",
v2.toChars(), v2._init.toChars(), vd.toChars());
//errors = true;
}
}
}
return errors;
Expand Down Expand Up @@ -602,7 +611,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
// Ensure no overflow
bool overflow;
const sz = addu(memsize, actualAlignment, overflow);
const sum = addu(ofs, sz, overflow);
addu(ofs, sz, overflow);
if (overflow) assert(0);

alignmember(alignment, memalignsize, &ofs);
Expand Down Expand Up @@ -641,7 +650,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol

/* Append vthis field (this.tupleof[$-1]) to make this aggregate type nested.
*/
final void makeNested()
extern (D) final void makeNested()
{
if (enclosing) // if already nested
return;
Expand Down Expand Up @@ -714,7 +723,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol

/* Append vthis2 field (this.tupleof[$-1]) to add a second context pointer.
*/
final void makeNested2()
extern (D) final void makeNested2()
{
if (vthis2)
return;
Expand Down
10 changes: 3 additions & 7 deletions dmd/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "dsymbol.h"
#include "objc.h"

class AliasThis;
class Identifier;
class Type;
class TypeFunction;
Expand Down Expand Up @@ -108,7 +109,7 @@ class AggregateDeclaration : public ScopeDsymbol
// it would be stored in TypeInfo_Class.defaultConstructor
CtorDeclaration *defaultCtor;

Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
AliasThis *aliasthis; // forward unresolved lookups to aliasthis
bool noDefaultCtor; // no default construction

DtorDeclarations dtors; // Array of destructors
Expand All @@ -130,8 +131,6 @@ class AggregateDeclaration : public ScopeDsymbol
Type *getType();
bool isDeprecated() const; // is aggregate deprecated?
bool isNested() const;
void makeNested();
void makeNested2();
bool isExport() const;
Dsymbol *searchCtor();

Expand Down Expand Up @@ -223,11 +222,7 @@ struct BaseClass
DArray<BaseClass> baseInterfaces; // if BaseClass is an interface, these
// are a copy of the InterfaceDeclaration::interfaces

BaseClass();
BaseClass(Type *type);

bool fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance);
void copyBaseInterfaces(BaseClasses *);
};

struct ClassFlags
Expand Down Expand Up @@ -298,6 +293,7 @@ class ClassDeclaration : public AggregateDeclaration
Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
ClassDeclaration *searchBase(Identifier *ident);
void finalizeSize();
bool hasMonitor();
bool isFuncHidden(FuncDeclaration *fd);
FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf);
bool isCOMclass() const;
Expand Down
58 changes: 56 additions & 2 deletions dmd/aliasthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import dmd.visitor;
extern (C++) final class AliasThis : Dsymbol
{
Identifier ident;
/// The symbol this `alias this` resolves to
Dsymbol sym;
/// Whether this `alias this` is deprecated or not
bool isDeprecated_;

extern (D) this(const ref Loc loc, Identifier ident)
{
Expand Down Expand Up @@ -58,6 +62,11 @@ extern (C++) final class AliasThis : Dsymbol
{
v.visit(this);
}

override bool isDeprecated() const
{
return this.isDeprecated_;
}
}

Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false)
Expand All @@ -71,7 +80,7 @@ Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false)
Type tthis = (e.op == TOK.type ? e.type : null);
e = new DotIdExp(loc, e, ad.aliasthis.ident);
e = e.expressionSemantic(sc);
if (tthis && ad.aliasthis.needThis())
if (tthis && ad.aliasthis.sym.needThis())
{
if (e.op == TOK.variable)
{
Expand Down Expand Up @@ -105,7 +114,9 @@ Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false)
e = e.expressionSemantic(sc);
}
e = resolveProperties(sc, e);
if (gag && global.endGagging(olderrors))
if (!gag)
ad.aliasthis.checkDeprecatedAliasThis(loc, sc);
else if (global.endGagging(olderrors))
e = null;
}

Expand All @@ -120,3 +131,46 @@ Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false)
}
return e;
}

/**
* Check if an `alias this` is deprecated
*
* Usually one would use `expression.checkDeprecated(scope, aliasthis)` to
* check if `expression` uses a deprecated `aliasthis`, but this calls
* `toPrettyChars` which lead to the following message:
* "Deprecation: alias this `fullyqualified.aggregate.__anonymous` is deprecated"
*
* Params:
* at = The `AliasThis` object to check
* loc = `Loc` of the expression triggering the access to `at`
* sc = `Scope` of the expression
* (deprecations do not trigger in deprecated scopes)
*
* Returns:
* Whether the alias this was reported as deprecated.
*/
bool checkDeprecatedAliasThis(AliasThis at, const ref Loc loc, Scope* sc)
{
import dmd.errors : deprecation;
import dmd.dsymbolsem : getMessage;

if (global.params.useDeprecated != DiagnosticReporting.off
&& at.isDeprecated() && !sc.isDeprecated())
{
const(char)* message = null;
for (Dsymbol p = at; p; p = p.parent)
{
message = p.depdecl ? p.depdecl.getMessage() : null;
if (message)
break;
}
if (message)
deprecation(loc, "`alias %s this` is deprecated - %s",
at.sym.toChars(), message);
else
deprecation(loc, "`alias %s this` is deprecated",
at.sym.toChars());
return true;
}
return false;
}
3 changes: 3 additions & 0 deletions dmd/aliasthis.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ class AliasThis : public Dsymbol
public:
// alias Identifier this;
Identifier *ident;
Dsymbol *sym;
bool isDeprecated_;

Dsymbol *syntaxCopy(Dsymbol *);
const char *kind() const;
AliasThis *isAliasThis() { return this; }
void accept(Visitor *v) { v->visit(this); }
bool isDeprecated() const { return this->isDeprecated_; }
};
14 changes: 14 additions & 0 deletions dmd/arrayop.d
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ Expression arrayOp(BinAssignExp e, Scope* sc)
if (tn && (!tn.isMutable() || !tn.isAssignable()))
{
e.error("slice `%s` is not mutable", e.e1.toChars());
if (e.op == TOK.addAssign)
checkPossibleAddCatError!(AddAssignExp, CatAssignExp)(e.isAddAssignExp);
return new ErrorExp();
}
if (e.e1.op == TOK.arrayLiteral)
Expand Down Expand Up @@ -342,5 +344,17 @@ bool isArrayOpOperand(Expression e)
ErrorExp arrayOpInvalidError(Expression e)
{
e.error("invalid array operation `%s` (possible missing [])", e.toChars());
if (e.op == TOK.add)
checkPossibleAddCatError!(AddExp, CatExp)(e.isAddExp());
else if (e.op == TOK.addAssign)
checkPossibleAddCatError!(AddAssignExp, CatAssignExp)(e.isAddAssignExp());
return new ErrorExp();
}

private void checkPossibleAddCatError(AddT, CatT)(AddT ae)
{
if (!ae.e2.type || ae.e2.type.ty != Tarray || !ae.e2.type.implicitConvTo(ae.e1.type))
return;
CatT ce = new CatT(ae.loc, ae.e1, ae.e2);
ae.errorSupplemental("did you mean to concatenate (`%s`) instead ?", ce.toChars());
}
4 changes: 2 additions & 2 deletions dmd/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,14 @@ extern (C++) final class CPPNamespaceDeclaration : AttribDeclaration
super(decl);
this.ident = ident;
this.exp = exp;
this.namespace = parent;
this.cppnamespace = parent;
}

override Dsymbol syntaxCopy(Dsymbol s)
{
assert(!s);
return new CPPNamespaceDeclaration(
this.ident, this.exp, Dsymbol.arraySyntaxCopy(this.decl), this.namespace);
this.ident, this.exp, Dsymbol.arraySyntaxCopy(this.decl), this.cppnamespace);
}

/**
Expand Down
Loading

0 comments on commit f3fe277

Please sign in to comment.