Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable' into merge_stable_convert
Browse files Browse the repository at this point in the history
Conflicts:
	changelog.dd
	src/opover.c
	src/posix.mak
	test/runnable/sdtor.d
  • Loading branch information
9rnsr committed Sep 24, 2015
2 parents 9d9cb89 + ef854c3 commit 726e2fc
Show file tree
Hide file tree
Showing 80 changed files with 2,886 additions and 1,156 deletions.
6 changes: 6 additions & 0 deletions changelog.dd
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ Macros:
STDMODREF = <a href="phobos/std_$1.html">$2</a>
XREF = <a href="phobos/std_$1.html#$2">$2</a>
CXREF = <a href="phobos/core_$1.html#$2">$2</a>

BUGZILLA = <a href="https://issues.dlang.org/show_bug.cgi?id=$0">Bugzilla $0</a>
PULL_REQUEST = $(LINK2 https://github.com/D-Programming-Language/$1/pull/$2, $1#$2)
DMDPR = $(PULL_REQUEST dmd,$1)

BOOKTABLE = <table><caption>$1</caption>$+</table>
5 changes: 5 additions & 0 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ class StructDeclaration : public AggregateDeclaration
Type *arg1type;
Type *arg2type;

// Even if struct is defined as non-root symbol, some built-in operations
// (e.g. TypeidExp, NewExp, ArrayLiteralExp, etc) request its TypeInfo.
// For those, today TypeInfo_Struct is generated in COMDAT.
bool requestTypeInfo;

StructDeclaration(Loc loc, Identifier *id);
Dsymbol *syntaxCopy(Dsymbol *s);
void semantic(Scope *sc);
Expand Down
7 changes: 6 additions & 1 deletion src/aliasthis.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
#include "declaration.h"
#include "tokens.h"

Expression *resolveAliasThis(Scope *sc, Expression *e)
Expression *resolveAliasThis(Scope *sc, Expression *e, bool gag)
{
AggregateDeclaration *ad = isAggregate(e->type);

if (ad && ad->aliasthis)
{
unsigned olderrors = gag ? global.startGagging() : 0;

Loc loc = e->loc;
Type *tthis = (e->op == TOKtype ? e->type : NULL);
e = new DotIdExp(loc, e, ad->aliasthis->ident);
Expand Down Expand Up @@ -64,6 +66,9 @@ Expression *resolveAliasThis(Scope *sc, Expression *e)
e = e->semantic(sc);
}
e = resolveProperties(sc, e);

if (gag && global.endGagging(olderrors))
e = NULL;
}

return e;
Expand Down
8 changes: 2 additions & 6 deletions src/arrayop.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,8 @@ Expression *buildArrayLoop(Expression *e, Parameters *fparams)
Parameter *param = new Parameter(STCconst, e->type, id, NULL);
fparams->shift(param);
Expression *ie = new IdentifierExp(Loc(), id);
Expressions *arguments = new Expressions();
Expression *index = new IdentifierExp(Loc(), Id::p);
arguments->push(index);
result = new ArrayExp(Loc(), ie, arguments);
result = new ArrayExp(Loc(), ie, index);
}

void visit(SliceExp *e)
Expand All @@ -459,10 +457,8 @@ Expression *buildArrayLoop(Expression *e, Parameters *fparams)
Parameter *param = new Parameter(STCconst, e->type, id, NULL);
fparams->shift(param);
Expression *ie = new IdentifierExp(Loc(), id);
Expressions *arguments = new Expressions();
Expression *index = new IdentifierExp(Loc(), Id::p);
arguments->push(index);
result = new ArrayExp(Loc(), ie, arguments);
result = new ArrayExp(Loc(), ie, index);
}

void visit(AssignExp *e)
Expand Down
26 changes: 26 additions & 0 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,32 @@ void ClassDeclaration::semantic(Scope *sc)
//printf("-ClassDeclaration::semantic(%s), type = %p\n", toChars(), type);
//members->print();

#if 0 // FIXME
LafterSizeok:
// The additions of special member functions should have its own
// sub-semantic analysis pass, and have to be deferred sometimes.
// See the case in compilable/test14838.d
for (size_t i = 0; i < fields.dim; i++)
{
VarDeclaration *v = fields[i];
Type *tb = v->type->baseElemOf();
if (tb->ty != Tstruct)
continue;
StructDeclaration *sd = ((TypeStruct *)tb)->sym;
if (sd->semanticRun >= PASSsemanticdone)
continue;

sc2->pop();

scope = scx ? scx : sc->copy();
scope->setNoFree();
scope->module->addDeferredSemantic(this);

//printf("\tdeferring %s\n", toChars());
return;
}
#endif

/* Look for special member functions.
* They must be in this class, not in a base class.
*/
Expand Down
13 changes: 12 additions & 1 deletion src/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ FuncDeclaration *buildOpAssign(StructDeclaration *sd, Scope *sc)
TypeFunction *tf = new TypeFunction(fparams, sd->handleType(), 0, LINKd, stc | STCref);

FuncDeclaration *fop = new FuncDeclaration(declLoc, Loc(), Id::assign, stc, tf);
fop->storage_class |= STCinference;

Expression *e = NULL;
if (stc & STCdisable)
Expand Down Expand Up @@ -310,7 +311,7 @@ FuncDeclaration *buildOpAssign(StructDeclaration *sd, Scope *sc)

fop->semantic(sc2);
fop->semantic2(sc2);
fop->semantic3(sc2);
// Bugzilla 15044: fop->semantic3 isn't run here for lazy forward reference resolution.

sc2->pop();
if (global.endGagging(errors)) // if errors happened
Expand Down Expand Up @@ -697,6 +698,8 @@ bool needToHash(StructDeclaration *sd)
TypeStruct *ts = (TypeStruct *)tv;
if (needToHash(ts->sym))
goto Lneed;
if (ts->sym->aliasthis) // Bugzilla 14948
goto Lneed;
}
}
Ldontneed:
Expand Down Expand Up @@ -797,6 +800,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc)
StructDeclaration *sdv = ((TypeStruct *)tv)->sym;
if (!sdv->postblit)
continue;
sdv->postblit->functionSemantic();

stc = mergeFuncAttrs(stc, sdv->postblit);
stc = mergeFuncAttrs(stc, sdv->dtor);
Expand Down Expand Up @@ -850,6 +854,8 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc)
*/
if (!sdv->dtor)
continue;
sdv->dtor->functionSemantic();

ex = new ThisExp(loc);
ex = new DotVarExp(loc, ex, v, 0);
if (v->type->toBasetype()->ty == Tstruct)
Expand Down Expand Up @@ -894,6 +900,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc)
{
//printf("Building __fieldPostBlit()\n");
PostBlitDeclaration *dd = new PostBlitDeclaration(declLoc, Loc(), stc, Id::__fieldPostblit);
dd->storage_class |= STCinference;
dd->fbody = a ? new CompoundStatement(loc, a) : NULL;
sd->postblits.shift(dd);
sd->members->push(dd);
Expand Down Expand Up @@ -928,6 +935,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc)
e = Expression::combine(e, ex);
}
PostBlitDeclaration *dd = new PostBlitDeclaration(declLoc, Loc(), stc, Id::__aggrPostblit);
dd->storage_class |= STCinference;
dd->fbody = new ExpStatement(loc, e);
sd->members->push(dd);
dd->semantic(sc);
Expand Down Expand Up @@ -971,6 +979,7 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc)
StructDeclaration *sdv = ((TypeStruct *)tv)->sym;
if (!sdv->dtor)
continue;
sdv->dtor->functionSemantic();

stc = mergeFuncAttrs(stc, sdv->dtor);
if (stc & STCdisable)
Expand Down Expand Up @@ -1023,6 +1032,7 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc)
{
//printf("Building __fieldDtor()\n");
DtorDeclaration *dd = new DtorDeclaration(declLoc, Loc(), stc, Id::__fieldDtor);
dd->storage_class |= STCinference;
dd->fbody = new ExpStatement(loc, e);
ad->dtors.shift(dd);
ad->members->push(dd);
Expand Down Expand Up @@ -1057,6 +1067,7 @@ FuncDeclaration *buildDtor(AggregateDeclaration *ad, Scope *sc)
e = Expression::combine(ex, e);
}
DtorDeclaration *dd = new DtorDeclaration(declLoc, Loc(), stc, Id::__aggrDtor);
dd->storage_class |= STCinference;
dd->fbody = new ExpStatement(loc, e);
ad->members->push(dd);
dd->semantic(sc);
Expand Down
2 changes: 1 addition & 1 deletion src/cppmangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ class VisualCPPMangler : public Visitor

t->accept(this);

if ((t->ty == Tpointer || t->ty == Treference) && global.params.is64bit)
if ((t->ty == Tpointer || t->ty == Treference || t->ty == Tclass) && global.params.is64bit)
{
buf.writeByte('E');
}
Expand Down
108 changes: 56 additions & 52 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ void AliasDeclaration::semantic(Scope *sc)
* try to alias y to 3.
*/
s = type->toDsymbol(sc);
if (errors != global.errors)
{
s = NULL;
type = Type::terror;
}
if (s && s == this)
{
error("cannot resolve");
Expand Down Expand Up @@ -1384,17 +1389,26 @@ void VarDeclaration::semantic(Scope *sc)
init = ei;
}

Expression *exp = ei->exp;
Expression *e1 = new VarExp(loc, this);
if (isBlit)
ei->exp = new BlitExp(loc, e1, ei->exp);
exp = new BlitExp(loc, e1, exp);
else
ei->exp = new ConstructExp(loc, e1, ei->exp);
exp = new ConstructExp(loc, e1, exp);
canassign++;
ei->exp = ei->exp->semantic(sc);
exp = exp->semantic(sc);
canassign--;
ei->exp->optimize(WANTvalue);
exp = exp->optimize(WANTvalue);

if (exp->op == TOKerror)
{
init = new ErrorInitializer();
ei = NULL;
}
else
ei->exp = exp;

if (isScope())
if (ei && isScope())
{
Expression *ex = ei->exp;
while (ex->op == TOKcomma)
Expand Down Expand Up @@ -1789,16 +1803,46 @@ bool lambdaCheckForNestedRef(Expression *e, Scope *sc);
bool VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
{
//printf("VarDeclaration::checkNestedReference() %s\n", toChars());
if (parent && parent != sc->parent &&
!isDataseg() && !(storage_class & STCmanifest) &&
sc->intypeof != 1 && !(sc->flags & SCOPEctfe))
if (sc->intypeof == 1 || (sc->flags & SCOPEctfe))
return false;
if (!parent || parent == sc->parent)
return false;
if (isDataseg() || (storage_class & STCmanifest))
return false;

// The current function
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
if (!fdthis)
return false; // out of function scope

Dsymbol *p = toParent2();

// Function literals from fdthis to p must be delegates
// TODO: here is similar to checkFrameAccess.
for (Dsymbol *s = fdthis; s && s != p; s = s->toParent2())
{
// function literal has reference to enclosing scope is delegate
if (FuncLiteralDeclaration *fld = s->isFuncLiteralDeclaration())
fld->tok = TOKdelegate;

if (FuncDeclaration *fd = s->isFuncDeclaration())
{
if (!fd->isThis() && !fd->isNested())
break;
}
if (AggregateDeclaration *ad2 = s->isAggregateDeclaration())
{
if (ad2->storage_class & STCstatic)
break;
}
}

if (1)
{
// The function that this variable is in
FuncDeclaration *fdv = toParent()->isFuncDeclaration();
// The current function
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
FuncDeclaration *fdv = p->isFuncDeclaration();

if (fdv && fdthis && fdv != fdthis)
if (fdv && fdv != fdthis)
{
// Add fdthis to nestedrefs[] if not already there
for (size_t i = 0; 1; i++)
Expand Down Expand Up @@ -1826,46 +1870,6 @@ bool VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
int lv = fdthis->getLevel(loc, sc, fdv);
if (lv == -2) // error
return true;
if (lv > 0 &&
fdv->isPureBypassingInference() >= PUREweak &&
fdthis->isPureBypassingInference() == PUREfwdref &&
fdthis->isInstantiated())
{
/* Bugzilla 9148 and 14039:
* void foo() pure {
* int x;
* void bar()() { // default is impure
* x = 1; // access to enclosing pure function context
* // means that bar should have weak purity.
* }
* }
*/
fdthis->flags &= ~FUNCFLAGpurityInprocess;
if (fdthis->type->ty == Tfunction)
{
TypeFunction *tf = (TypeFunction *)fdthis->type;
if (tf->deco)
{
tf = (TypeFunction *)tf->copy();
tf->purity = PUREfwdref;
tf->deco = NULL;
tf->deco = tf->merge()->deco;
}
else
tf->purity = PUREfwdref;
fdthis->type = tf;
}
}
}

// Function literals from fdthis to fdv must be delegates
for (Dsymbol *s = fdthis; s && s != fdv; s = s->toParent2())
{
// function literal has reference to enclosing scope is delegate
if (FuncLiteralDeclaration *fld = s->isFuncLiteralDeclaration())
{
fld->tok = TOKdelegate;
}
}

// Add this to fdv->closureVars[] if not already there
Expand Down
1 change: 1 addition & 0 deletions src/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ enum PINLINE;
#define STCnogc 0x40000000000LL // @nogc
#define STCvolatile 0x80000000000LL // destined for volatile in the back end
#define STCreturn 0x100000000000LL // 'return ref' for function parameters
#define STCinference 0x200000000000LL // do attribute inference

const StorageClass STCStorageClass = (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal |
STCabstract | STCsynchronized | STCdeprecated | STCoverride | STClazy | STCalias |
Expand Down
Loading

0 comments on commit 726e2fc

Please sign in to comment.