16 changes: 9 additions & 7 deletions gcc/d/dfrontend/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

bool checkNestedRef(Dsymbol *s, Dsymbol *p);
VarDeclaration *copyToTemp(StorageClass stc, const char *name, Expression *e);
Expression *semantic(Expression *e, Scope *sc);

/************************************
* Check to see the aggregate type is nested and its context pointer is
Expand Down Expand Up @@ -352,7 +353,7 @@ void AliasDeclaration::aliasSemantic(Scope *sc)
return;

Expression *e = new FuncExp(loc, aliassym);
e = e->semantic(sc);
e = ::semantic(e, sc);
if (e->op == TOKfunction)
{
FuncExp *fe = (FuncExp *)e;
Expand Down Expand Up @@ -1009,7 +1010,8 @@ void VarDeclaration::semantic(Scope *sc)
TypeTuple *tt = (TypeTuple *)tb;
size_t nelems = Parameter::dim(tt->arguments);
Expression *ie = (_init && !_init->isVoidInitializer()) ? _init->toExpression() : NULL;
if (ie) ie = ie->semantic(sc);
if (ie)
ie = ::semantic(ie, sc);

if (nelems > 0 && ie)
{
Expand Down Expand Up @@ -1389,7 +1391,7 @@ void VarDeclaration::semantic(Scope *sc)

Expression *e = tv->defaultInitLiteral(loc);
e = new BlitExp(loc, new VarExp(loc, this), e);
e = e->semantic(sc);
e = ::semantic(e, sc);
_init = new ExpInitializer(loc, e);
goto Ldtor;
}
Expand Down Expand Up @@ -1469,7 +1471,7 @@ void VarDeclaration::semantic(Scope *sc)
else
exp = new ConstructExp(loc, e1, exp);
canassign++;
exp = exp->semantic(sc);
exp = ::semantic(exp, sc);
canassign--;
exp = exp->optimize(WANTvalue);

Expand Down Expand Up @@ -1543,7 +1545,7 @@ void VarDeclaration::semantic(Scope *sc)

bool needctfe = isDataseg() || (storage_class & STCmanifest);
if (needctfe) sc = sc->startCTFE();
exp = exp->semantic(sc);
exp = ::semantic(exp, sc);
exp = resolveProperties(sc, exp);
if (needctfe) sc = sc->endCTFE();

Expand Down Expand Up @@ -1603,9 +1605,9 @@ void VarDeclaration::semantic(Scope *sc)
if (edtor)
{
if (sc->func && storage_class & (STCstatic | STCgshared))
edtor = edtor->semantic(sc->_module->_scope);
edtor = ::semantic(edtor, sc->_module->_scope);
else
edtor = edtor->semantic(sc);
edtor = ::semantic(edtor, sc);

#if 0 // currently disabled because of std.stdio.stdin, stdout and stderr
if (isDataseg() && !(storage_class & STCextern))
Expand Down
13 changes: 7 additions & 6 deletions gcc/d/dfrontend/delegatize.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@
#include "init.h"
#include "tokens.h"


bool walkPostorder(Expression *e, StoppableVisitor *v);
void lambdaSetParent(Expression *e, Scope *sc);
bool lambdaCheckForNestedRef(Expression *e, Scope *sc);
Expression *semantic(Expression *e, Scope *sc);

/********************************************
* Convert from expression to delegate that returns the expression,
* i.e. convert:
* expr
* to:
* typeof(expr) delegate() { return expr; }
*/

bool walkPostorder(Expression *e, StoppableVisitor *v);
void lambdaSetParent(Expression *e, Scope *sc);
bool lambdaCheckForNestedRef(Expression *e, Scope *sc);

Expression *toDelegate(Expression *e, Type* t, Scope *sc)
{
//printf("Expression::toDelegate(t = %s) %s\n", t->toChars(), e->toChars());
Expand Down Expand Up @@ -63,7 +64,7 @@ Expression *toDelegate(Expression *e, Type* t, Scope *sc)
fld->fbody = s;

e = new FuncExp(loc, fld);
e = e->semantic(sc);
e = semantic(e, sc);
return e;
}

Expand Down
18 changes: 10 additions & 8 deletions gcc/d/dfrontend/denum.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "declaration.h"
#include "init.h"

Expression *semantic(Expression *e, Scope *sc);

/********************************* EnumDeclaration ****************************/

EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype)
Expand Down Expand Up @@ -340,7 +342,7 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id)
*/
Expression *ec = new CmpExp(id == Id::max ? TOKgt : TOKlt, em->loc, e, *pval);
inuse++;
ec = ec->semantic(em->_scope);
ec = ::semantic(ec, em->_scope);
inuse--;
ec = ec->ctfeInterpret();
if (ec->toInteger())
Expand Down Expand Up @@ -543,7 +545,7 @@ void EnumMember::semantic(Scope *sc)
{
Expression *e = value();
assert(e->dyncast() == DYNCAST_EXPRESSION);
e = e->semantic(sc);
e = ::semantic(e, sc);
e = resolveProperties(sc, e);
e = e->ctfeInterpret();
if (e->op == TOKerror)
Expand Down Expand Up @@ -661,14 +663,14 @@ void EnumMember::semantic(Scope *sc)
Type *tprev = eprev->type->equals(ed->type) ? ed->memtype : eprev->type;

Expression *emax = tprev->getProperty(ed->loc, Id::max, 0);
emax = emax->semantic(sc);
emax = ::semantic(emax, sc);
emax = emax->ctfeInterpret();

// Set value to (eprev + 1).
// But first check that (eprev != emax)
assert(eprev);
Expression *e = new EqualExp(TOKequal, loc, eprev, emax);
e = e->semantic(sc);
e = ::semantic(e, sc);
e = e->ctfeInterpret();
if (e->toInteger())
{
Expand All @@ -678,7 +680,7 @@ void EnumMember::semantic(Scope *sc)

// Now set e to (eprev + 1)
e = new AddExp(loc, eprev, new IntegerExp(loc, 1, Type::tint32));
e = e->semantic(sc);
e = ::semantic(e, sc);
e = e->castTo(sc, eprev->type);
e = e->ctfeInterpret();

Expand All @@ -687,7 +689,7 @@ void EnumMember::semantic(Scope *sc)
{
assert(emprev->origValue);
origValue = new AddExp(loc, emprev->origValue, new IntegerExp(loc, 1, Type::tint32));
origValue = origValue->semantic(sc);
origValue = ::semantic(origValue, sc);
origValue = origValue->ctfeInterpret();
}

Expand All @@ -697,7 +699,7 @@ void EnumMember::semantic(Scope *sc)
{
// Check that e != eprev (not always true for floats)
Expression *etest = new EqualExp(TOKequal, loc, e, eprev);
etest = etest->semantic(sc);
etest = ::semantic(etest, sc);
etest = etest->ctfeInterpret();
if (etest->toInteger())
{
Expand All @@ -720,5 +722,5 @@ Expression *EnumMember::getVarExp(Loc loc, Scope *sc)
if (errors)
return new ErrorExp();
Expression *e = new VarExp(loc, this);
return e->semantic(sc);
return ::semantic(e, sc);
}
3 changes: 2 additions & 1 deletion gcc/d/dfrontend/dinterpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum CtfeGoal
bool walkPostorder(Expression *e, StoppableVisitor *v);
Expression *interpret(Statement *s, InterState *istate);
Expression *interpret(Expression *e, InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expression *semantic(Expression *e, Scope *sc);

#define LOG 0
#define LOGASSIGN 0
Expand Down Expand Up @@ -2398,7 +2399,7 @@ class Interpreter : public Visitor
e = s->dsym->type->defaultInitLiteral(loc);
if (e->op == TOKerror)
error(loc, "CTFE failed because of previous errors in %s.init", s->toChars());
e = e->semantic(NULL);
e = ::semantic(e, NULL);
if (e->op == TOKerror)
e = CTFEExp::cantexp;
else // Convert NULL to CTFEExp
Expand Down
3 changes: 2 additions & 1 deletion gcc/d/dfrontend/dstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Type *getTypeInfoType(Type *t, Scope *sc);
TypeTuple *toArgTypes(Type *t);
void unSpeculative(Scope *sc, RootObject *o);
bool MODimplicitConv(MOD modfrom, MOD modto);
Expression *resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads);

FuncDeclaration *StructDeclaration::xerreq; // object.xopEquals
FuncDeclaration *StructDeclaration::xerrcmp; // object.xopCmp
Expand Down Expand Up @@ -313,7 +314,7 @@ void AggregateDeclaration::semantic3(Scope *sc)
ti->semantic(sc3);
ti->semantic2(sc3);
ti->semantic3(sc3);
Expression *e = DsymbolExp::resolve(Loc(), sc3, ti->toAlias(), false);
Expression *e = resolve(Loc(), sc3, ti->toAlias(), false);

sc3->endCTFE();

Expand Down
5 changes: 3 additions & 2 deletions gcc/d/dfrontend/dsymbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
bool symbolIsVisible(Dsymbol *origin, Dsymbol *s);
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
int ScopeDsymbol_foreach(Scope *sc, Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn = NULL);
Expression *semantic(Expression *e, Scope *sc);


/****************************** Dsymbol ******************************/
Expand Down Expand Up @@ -1632,7 +1633,7 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags)

Objects *tiargs = new Objects();
Expression *edim = new IntegerExp(Loc(), dim, Type::tsize_t);
edim = edim->semantic(sc);
edim = ::semantic(edim, sc);
tiargs->push(edim);
e = new DotTemplateInstanceExp(loc, ce, td->ident, tiargs);
}
Expand All @@ -1652,7 +1653,7 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags)
assert(d);
e = new DotVarExp(loc, ce, d);
}
e = e->semantic(sc);
e = ::semantic(e, sc);
if (!e->type)
exp->error("%s has no value", e->toChars());
t = e->type->toBasetype();
Expand Down
22 changes: 21 additions & 1 deletion gcc/d/dfrontend/dsymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class TypeTuple;
class WithStatement;
class LabelDsymbol;
class ScopeDsymbol;
class ForwardingScopeDsymbol;
class TemplateDeclaration;
class TemplateInstance;
class TemplateMixin;
class ForwardingAttribDeclaration;
class Nspace;
class EnumMember;
class WithScopeSymbol;
Expand Down Expand Up @@ -248,8 +250,10 @@ class Dsymbol : public RootObject
virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; }
virtual TemplateInstance *isTemplateInstance() { return NULL; }
virtual TemplateMixin *isTemplateMixin() { return NULL; }
virtual ForwardingAttribDeclaration *isForwardingAttribDeclaration() { return NULL; }
virtual Nspace *isNspace() { return NULL; }
virtual Declaration *isDeclaration() { return NULL; }
virtual StorageClassDeclaration *isStorageClassDeclaration(){ return NULL; }
virtual ThisDeclaration *isThisDeclaration() { return NULL; }
virtual TypeInfoDeclaration *isTypeInfoDeclaration() { return NULL; }
virtual TupleDeclaration *isTupleDeclaration() { return NULL; }
Expand All @@ -275,6 +279,7 @@ class Dsymbol : public RootObject
virtual UnionDeclaration *isUnionDeclaration() { return NULL; }
virtual InterfaceDeclaration *isInterfaceDeclaration() { return NULL; }
virtual ScopeDsymbol *isScopeDsymbol() { return NULL; }
virtual ForwardingScopeDsymbol *isForwardingScopeDsymbol() { return NULL; }
virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; }
virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; }
virtual Import *isImport() { return NULL; }
Expand Down Expand Up @@ -308,7 +313,7 @@ class ScopeDsymbol : public Dsymbol
Dsymbol *syntaxCopy(Dsymbol *s);
Dsymbol *search(Loc loc, Identifier *ident, int flags = SearchLocalsOnly);
OverloadSet *mergeOverloadSet(Identifier *ident, OverloadSet *os, Dsymbol *s);
void importScope(Dsymbol *s, Prot protection);
virtual void importScope(Dsymbol *s, Prot protection);
void addAccessiblePackage(Package *p, Prot protection);
virtual bool isPackageAccessible(Package *p, Prot protection, int flags = 0);
bool isforwardRef();
Expand Down Expand Up @@ -372,6 +377,21 @@ class OverloadSet : public Dsymbol
void accept(Visitor *v) { v->visit(this); }
};

// Forwarding ScopeDsymbol

class ForwardingScopeDsymbol : public ScopeDsymbol
{
ScopeDsymbol *forward;

Dsymbol *symtabInsert(Dsymbol *s);
Dsymbol *symtabLookup(Dsymbol *s, Identifier *id);
void importScope(Dsymbol *s, Prot protection);
void semantic(Scope *sc);
const char *kind();

ForwardingScopeDsymbol *isForwardingScopeDsymbol() { return this; }
};

// Table of Dsymbol's

class DsymbolTable : public RootObject
Expand Down
24 changes: 13 additions & 11 deletions gcc/d/dfrontend/dtemplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static int arrayObjectMatch(Objects *oa1, Objects *oa2);
static unsigned char deduceWildHelper(Type *t, Type **at, Type *tparam);
static MATCH deduceTypeHelper(Type *t, Type **at, Type *tparam);
static Type *reliesOnTident(Type *t, TemplateParameters *tparams = NULL, size_t iStart = 0);
Expression *semantic(Expression *e, Scope *sc);

/********************************************
* These functions substitute for dynamic_cast. dynamic_cast does not work
Expand Down Expand Up @@ -848,7 +849,7 @@ bool TemplateDeclaration::evaluateConstraint(
ti->inst = ti; // temporary instantiation to enable genIdent()

//printf("\tscx->parent = %s %s\n", scx->parent->kind(), scx->parent->toPrettyChars());
e = e->semantic(scx);
e = ::semantic(e, scx);
e = resolveProperties(scx, e);

ti->inst = NULL;
Expand Down Expand Up @@ -1687,7 +1688,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(

// Deduce prmtype from the defaultArg.
farg = fparam->defaultArg->syntaxCopy();
farg = farg->semantic(paramscope);
farg = ::semantic(farg, paramscope);
farg = resolveProperties(paramscope, farg);
}
else
Expand Down Expand Up @@ -4038,7 +4039,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
// (it may be from a parent template, for example)
}

e2 = e2->semantic(sc); // Bugzilla 13417
e2 = ::semantic(e2, sc); // Bugzilla 13417
e2 = e2->ctfeInterpret();

//printf("e1 = %s, type = %s %d\n", e1->toChars(), e1->type->toChars(), e1->type->ty);
Expand Down Expand Up @@ -4659,7 +4660,8 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
e->fd->treq = tparam;

TemplateInstance *ti = new TemplateInstance(e->loc, e->td, tiargs);
Expression *ex = (new ScopeExp(e->loc, ti))->semantic(e->td->_scope);
Expression *ex = new ScopeExp(e->loc, ti);
ex = ::semantic(ex, e->td->_scope);

// Reset inference target for the later re-semantic
e->fd->treq = NULL;
Expand Down Expand Up @@ -5185,7 +5187,7 @@ static RootObject *aliasParameterSemantic(Loc loc, Scope *sc, RootObject *o, Tem
else if (ea)
{
sc = sc->startCTFE();
ea = ea->semantic(sc);
ea = ::semantic(ea, sc);
sc = sc->endCTFE();
o = ea->ctfeInterpret();
}
Expand Down Expand Up @@ -5475,7 +5477,7 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, RootObject *oarg,
goto Lnomatch;

ei = new VarExp(loc, f);
ei = ei->semantic(sc);
ei = ::semantic(ei, sc);

/* If a function is really property-like, and then
* it's CTFEable, ei will be a literal expression.
Expand Down Expand Up @@ -5535,15 +5537,15 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, RootObject *oarg,
Expression *e = specValue;

sc = sc->startCTFE();
e = e->semantic(sc);
e = ::semantic(e, sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();
e = e->implicitCastTo(sc, vt);
e = e->ctfeInterpret();

ei = ei->syntaxCopy();
sc = sc->startCTFE();
ei = ei->semantic(sc);
ei = ::semantic(ei, sc);
sc = sc->endCTFE();
ei = ei->implicitCastTo(sc, vt);
ei = ei->ctfeInterpret();
Expand Down Expand Up @@ -5619,7 +5621,7 @@ RootObject *TemplateValueParameter::defaultArg(Loc instLoc, Scope *sc)
if (e)
{
e = e->syntaxCopy();
e = e->semantic(sc);
e = ::semantic(e, sc);
e = resolveProperties(sc, e);
e = e->resolveLoc(instLoc, sc); // use the instantiated loc
e = e->optimize(WANTvalue);
Expand Down Expand Up @@ -6787,7 +6789,7 @@ bool TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f
//printf("+[%d] ea = %s %s\n", j, Token::toChars(ea->op), ea->toChars());
if (flags & 1) // only used by __traits
{
ea = ea->semantic(sc);
ea = ::semantic(ea, sc);

// must not interpret the args, excepting template parameters
if (ea->op != TOKvar ||
Expand All @@ -6799,7 +6801,7 @@ bool TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f
else
{
sc = sc->startCTFE();
ea = ea->semantic(sc);
ea = ::semantic(ea, sc);
sc = sc->endCTFE();

if (ea->op == TOKvar)
Expand Down
11,139 changes: 1,585 additions & 9,554 deletions gcc/d/dfrontend/expression.c

Large diffs are not rendered by default.

107 changes: 1 addition & 106 deletions gcc/d/dfrontend/expression.h

Large diffs are not rendered by default.

8,806 changes: 8,806 additions & 0 deletions gcc/d/dfrontend/expressionsem.c

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions gcc/d/dfrontend/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ bool checkEscapeRef(Scope *sc, Expression *e, bool gag);
bool checkNestedRef(Dsymbol *s, Dsymbol *p);
Statement *semantic(Statement *s, Scope *sc);
void semantic(Catch *c, Scope *sc);
Expression *resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads);
Expression *semantic(Expression *e, Scope *sc);

void genCmain(Scope *sc);
RET retStyle(TypeFunction *tf);
Expand Down Expand Up @@ -1743,7 +1745,7 @@ void FuncDeclaration::semantic3(Scope *sc)
{
Expression *e1 = new SuperExp(Loc());
Expression *e = new CallExp(Loc(), e1);
e = e->semantic(sc2);
e = ::semantic(e, sc2);

Statement *s = new ExpStatement(Loc(), e);
fbody = new CompoundStatement(Loc(), s, fbody);
Expand Down Expand Up @@ -1820,7 +1822,7 @@ void FuncDeclaration::semantic3(Scope *sc)
else
e = new HaltExp(endloc);
e = new CommaExp(Loc(), e, f->next->defaultInit());
e = e->semantic(sc2);
e = ::semantic(e, sc2);
Statement *s = new ExpStatement(Loc(), e);
fbody = new CompoundStatement(Loc(), fbody, s);
}
Expand Down Expand Up @@ -2004,7 +2006,7 @@ void FuncDeclaration::semantic3(Scope *sc)
Expression *e = new VarExp(Loc(), v_arguments);
e = new DotIdExp(Loc(), e, Id::elements);
e = new ConstructExp(Loc(), _arguments, e);
e = e->semantic(sc2);
e = ::semantic(e, sc2);

_arguments->_init = new ExpInitializer(Loc(), e);
DeclarationExp *de = new DeclarationExp(Loc(), _arguments);
Expand Down Expand Up @@ -2044,7 +2046,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (tintro)
{
e = e->implicitCastTo(sc, tintro->nextOf());
e = e->semantic(sc);
e = ::semantic(e, sc);
}
ReturnStatement *s = new ReturnStatement(Loc(), e);
a->push(s);
Expand Down Expand Up @@ -2115,7 +2117,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (isStatic())
{
// The monitor is in the ClassInfo
vsync = new DotIdExp(loc, DsymbolExp::resolve(loc, sc2, cd, false), Id::classinfo);
vsync = new DotIdExp(loc, resolve(loc, sc2, cd, false), Id::classinfo);
}
else
{
Expand Down Expand Up @@ -4162,7 +4164,7 @@ Expression *addInvariant(Loc loc, Scope *sc, AggregateDeclaration *ad, VarDeclar
v = v->addressOf();
e = new StringExp(Loc(), (char *)"null this");
e = new AssertExp(loc, v, e);
e = e->semantic(sc);
e = semantic(e, sc);
}
return e;
}
Expand Down
1 change: 1 addition & 0 deletions gcc/d/dfrontend/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Param
bool vfield; // identify non-mutable field variables
bool vcomplex; // identify complex/imaginary type usage
char symdebug; // insert debug symbolic information
bool symdebugref; // insert debug information for all referenced types, too
bool alwaysframe; // always emit standard stack frame
bool optimize; // run optimizer
bool map; // generate linker .map file
Expand Down
2 changes: 2 additions & 0 deletions gcc/d/dfrontend/hdrgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <string.h> // memset()

#include "dsymbol.h"

void genhdrfile(Module *m);

struct HdrGenState
Expand Down
5 changes: 0 additions & 5 deletions gcc/d/dfrontend/idgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ Msgtable msgtable[] =
{ "values" },
{ "rehash" },

{ "sort" },
{ "reverse" },

{ "property" },
{ "nogc" },
{ "safe" },
Expand Down Expand Up @@ -258,8 +255,6 @@ Msgtable msgtable[] =
{ "FpopFront", "popFront" },
{ "FpopBack", "popBack" },

{ "adReverse", "_adReverse" },

// For internal functions
{ "aaLen", "_aaLen" },
{ "aaKeys", "_aaKeys" },
Expand Down
9 changes: 5 additions & 4 deletions gcc/d/dfrontend/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tokens.h"

FuncDeclaration *isFuncAddress(Expression *e, bool *hasOverloads = NULL);
Expression *semantic(Expression *e, Scope *sc);

/********************************** Initializer *******************************/

Expand Down Expand Up @@ -463,7 +464,7 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, NeedInterpret needIn
if (idx)
{
sc = sc->startCTFE();
idx = idx->semantic(sc);
idx = ::semantic(idx, sc);
sc = sc->endCTFE();
idx = idx->ctfeInterpret();
index[i] = idx;
Expand Down Expand Up @@ -826,7 +827,7 @@ bool arrayHasNonConstPointers(Expressions *elems)
Initializer *ExpInitializer::inferType(Scope *sc)
{
//printf("ExpInitializer::inferType() %s\n", toChars());
exp = exp->semantic(sc);
exp = ::semantic(exp, sc);
exp = resolveProperties(sc, exp);

if (exp->op == TOKscope)
Expand Down Expand Up @@ -874,7 +875,7 @@ Initializer *ExpInitializer::semantic(Scope *sc, Type *t, NeedInterpret needInte
{
//printf("ExpInitializer::semantic(%s), type = %s\n", exp->toChars(), t->toChars());
if (needInterpret) sc = sc->startCTFE();
exp = exp->semantic(sc);
exp = ::semantic(exp, sc);
exp = resolveProperties(sc, exp);
if (needInterpret) sc = sc->endCTFE();
if (exp->op == TOKerror)
Expand Down Expand Up @@ -960,7 +961,7 @@ Initializer *ExpInitializer::semantic(Scope *sc, Type *t, NeedInterpret needInte
e = new StructLiteralExp(loc, sd, NULL);
e = new DotIdExp(loc, e, Id::ctor);
e = new CallExp(loc, e, exp);
e = e->semantic(sc);
e = ::semantic(e, sc);
if (needInterpret)
exp = e->ctfeInterpret();
else
Expand Down
243 changes: 64 additions & 179 deletions gcc/d/dfrontend/mtype.c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions gcc/d/dfrontend/nspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#pragma once
#endif /* __DMC__ */

#include "dsymbol.h"

/* A namespace corresponding to a C++ namespace.
* Implies extern(C++).
*/
Expand Down
83 changes: 43 additions & 40 deletions gcc/d/dfrontend/opover.c

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion gcc/d/dfrontend/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "enum.h"
#include "ctfe.h"

Expression *semantic(Expression *e, Scope *sc);

/*************************************
* If variable has a const initializer,
* return that initializer.
Expand Down Expand Up @@ -97,7 +99,7 @@ Expression *expandVar(int result, VarDeclaration *v)
{
// const var initialized with non-const expression
ei = ei->implicitCastTo(NULL, v->type);
ei = ei->semantic(NULL);
ei = semantic(ei, NULL);
}
else
goto L1;
Expand Down
5 changes: 3 additions & 2 deletions gcc/d/dfrontend/sideeffect.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

bool walkPostorder(Expression *e, StoppableVisitor *v);
bool lambdaHasSideEffect(Expression *e);
Expression *semantic(Expression *e, Scope *sc);

/**************************************************
* Front-end expression rewriting should create temporary variables for
Expand Down Expand Up @@ -431,8 +432,8 @@ Expression *extractSideEffect(Scope *sc, const char *name,

Expression *de = new DeclarationExp(vd->loc, vd);
Expression *ve = new VarExp(vd->loc, vd);
de = de->semantic(sc);
ve = ve->semantic(sc);
de = semantic(de, sc);
ve = semantic(ve, sc);

*e0 = Expression::combine(*e0, de);
return ve;
Expand Down
5 changes: 3 additions & 2 deletions gcc/d/dfrontend/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bool walkPostorder(Statement *s, StoppableVisitor *v);
StorageClass mergeFuncAttrs(StorageClass s1, FuncDeclaration *f);
bool checkEscapeRef(Scope *sc, Expression *e, bool gag);
VarDeclaration *copyToTemp(StorageClass stc, const char *name, Expression *e);
Expression *semantic(Expression *e, Scope *sc);

Identifier *fixupLabelName(Scope *sc, Identifier *ident)
{
Expand Down Expand Up @@ -897,7 +898,7 @@ Statements *ExpStatement::flatten(Scope *sc)
Dsymbol *d = ((DeclarationExp *)exp)->declaration;
if (TemplateMixin *tm = d->isTemplateMixin())
{
Expression *e = exp->semantic(sc);
Expression *e = semantic(exp, sc);
if (e->op == TOKerror || tm->errors)
{
Statements *a = new Statements();
Expand Down Expand Up @@ -953,7 +954,7 @@ Statements *CompileStatement::flatten(Scope *sc)
{
//printf("CompileStatement::flatten() %s\n", exp->toChars());
sc = sc->startCTFE();
exp = exp->semantic(sc);
exp = semantic(exp, sc);
exp = resolveProperties(sc, exp);
sc = sc->endCTFE();

Expand Down
22 changes: 22 additions & 0 deletions gcc/d/dfrontend/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TryFinallyStatement;
class CaseStatement;
class DefaultStatement;
class LabelStatement;
class StaticForeach;

// Back end
struct code;
Expand Down Expand Up @@ -110,6 +111,7 @@ class Statement : public RootObject
virtual GotoCaseStatement *isGotoCaseStatement() { return NULL; }
virtual BreakStatement *isBreakStatement() { return NULL; }
virtual DtorExpStatement *isDtorExpStatement() { return NULL; }
virtual ForwardingStatement *isForwardingStatement() { return NULL; }
virtual void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -235,6 +237,15 @@ class ScopeStatement : public Statement
void accept(Visitor *v) { v->visit(this); }
};

class ForwardingStatement : public Statement
{
Statement *statement;
ForwardingScopeDsymbol *sym;

ForwardingStatement *isForwardingStatement() { return this; }
void accept(Visitor *v) { v->visit(this); }
};

class WhileStatement : public Statement
{
public:
Expand Down Expand Up @@ -368,6 +379,17 @@ class ConditionalStatement : public Statement
void accept(Visitor *v) { v->visit(this); }
};

class StaticForeachStatement : public Statement
{
public:
StaticForeach *sfe;

Statement *syntaxCopy();
Statements *flatten(Scope *sc);

void accept(Visitor *v) { v->visit(this); }
};

class PragmaStatement : public Statement
{
public:
Expand Down
71 changes: 36 additions & 35 deletions gcc/d/dfrontend/statementsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Identifier *fixupLabelName(Scope *sc, Identifier *ident);
FuncDeclaration *isFuncAddress(Expression *e, bool *hasOverloads = NULL);
VarDeclaration *copyToTemp(StorageClass stc, const char *name, Expression *e);

Expression *semantic(Expression *e, Scope *sc);
Statement *semantic(Statement *s, Scope *sc);
void semantic(Catch *c, Scope *sc);
Statement *semanticNoScope(Statement *s, Scope *sc);
Expand Down Expand Up @@ -90,7 +91,7 @@ class StatementSemanticVisitor : public Visitor
if (s->exp->op == TOKcomma)
((CommaExp *)s->exp)->allowCommaExp = true;

s->exp = s->exp->semantic(sc);
s->exp = semantic(s->exp, sc);
s->exp = resolveProperties(sc, s->exp);
s->exp = s->exp->addDtorHook(sc);
if (FuncDeclaration *f = isFuncAddress(s->exp))
Expand Down Expand Up @@ -373,7 +374,7 @@ class StatementSemanticVisitor : public Visitor
if (ds->condition->op == TOKdotid)
((DotIdExp *)ds->condition)->noderef = true;

ds->condition = ds->condition->semantic(sc);
ds->condition = semantic(ds->condition, sc);
ds->condition = resolveProperties(sc, ds->condition);
ds->condition = ds->condition->optimize(WANTvalue);
ds->condition = checkGC(sc, ds->condition);
Expand Down Expand Up @@ -440,7 +441,7 @@ class StatementSemanticVisitor : public Visitor
if (fs->condition->op == TOKdotid)
((DotIdExp *)fs->condition)->noderef = true;

fs->condition = fs->condition->semantic(sc);
fs->condition = semantic(fs->condition, sc);
fs->condition = resolveProperties(sc, fs->condition);
fs->condition = fs->condition->optimize(WANTvalue);
fs->condition = checkGC(sc, fs->condition);
Expand All @@ -450,7 +451,7 @@ class StatementSemanticVisitor : public Visitor
{
if (fs->increment->op == TOKcomma)
((CommaExp *)fs->increment)->allowCommaExp = true;
fs->increment = fs->increment->semantic(sc);
fs->increment = semantic(fs->increment, sc);
fs->increment = resolveProperties(sc, fs->increment);
fs->increment = fs->increment->optimize(WANTvalue);
fs->increment = checkGC(sc, fs->increment);
Expand Down Expand Up @@ -490,7 +491,7 @@ class StatementSemanticVisitor : public Visitor
fs->func = fs->func->fes->func;

VarDeclaration *vinit = NULL;
fs->aggr = fs->aggr->semantic(sc);
fs->aggr = semantic(fs->aggr, sc);
fs->aggr = resolveProperties(sc, fs->aggr);
fs->aggr = fs->aggr->optimize(WANTvalue);
if (fs->aggr->op == TOKerror)
Expand Down Expand Up @@ -1232,7 +1233,7 @@ class StatementSemanticVisitor : public Visitor
FuncLiteralDeclaration *fld = new FuncLiteralDeclaration(loc, Loc(), tfld, TOKdelegate, fs);
fld->fbody = fs->_body;
Expression *flde = new FuncExp(loc, fld);
flde = flde->semantic(sc);
flde = semantic(flde, sc);
fld->tookAddressOf = 0;

// Resolve any forward referenced goto's
Expand All @@ -1253,7 +1254,7 @@ class StatementSemanticVisitor : public Visitor
if (vinit)
{
e = new DeclarationExp(loc, vinit);
e = e->semantic(sc);
e = semantic(e, sc);
if (e->op == TOKerror)
goto Lerror2;
}
Expand Down Expand Up @@ -1398,7 +1399,7 @@ class StatementSemanticVisitor : public Visitor
fs->aggr = ((DelegateExp *)fs->aggr)->e1;
}
ec = new CallExp(loc, fs->aggr, flde);
ec = ec->semantic(sc);
ec = semantic(ec, sc);
if (ec->op == TOKerror)
goto Lerror2;
if (ec->type != Type::tint32)
Expand All @@ -1419,7 +1420,7 @@ class StatementSemanticVisitor : public Visitor
*/
ec = new DotIdExp(loc, fs->aggr, sapply->ident);
ec = new CallExp(loc, ec, flde);
ec = ec->semantic(sc);
ec = semantic(ec, sc);
if (ec->op == TOKerror)
goto Lerror2;
if (ec->type != Type::tint32)
Expand Down Expand Up @@ -1479,7 +1480,7 @@ class StatementSemanticVisitor : public Visitor
{
//printf("ForeachRangeStatement::semantic() %p\n", fs);
Loc loc = fs->loc;
fs->lwr = fs->lwr->semantic(sc);
fs->lwr = semantic(fs->lwr, sc);
fs->lwr = resolveProperties(sc, fs->lwr);
fs->lwr = fs->lwr->optimize(WANTvalue);
if (!fs->lwr->type)
Expand All @@ -1489,7 +1490,7 @@ class StatementSemanticVisitor : public Visitor
return setError();
}

fs->upr = fs->upr->semantic(sc);
fs->upr = semantic(fs->upr, sc);
fs->upr = resolveProperties(sc, fs->upr);
fs->upr = fs->upr->optimize(WANTvalue);
if (!fs->upr->type)
Expand All @@ -1512,7 +1513,7 @@ class StatementSemanticVisitor : public Visitor
{
// See if upr-1 fits in prm->type
Expression *limit = new MinExp(loc, fs->upr, new IntegerExp(1));
limit = limit->semantic(sc);
limit = semantic(limit, sc);
limit = limit->optimize(WANTvalue);
if (!limit->implicitConvTo(fs->prm->type))
{
Expand Down Expand Up @@ -1688,7 +1689,7 @@ class StatementSemanticVisitor : public Visitor
DeclarationExp *de = new DeclarationExp(ifs->loc, ifs->match);
VarExp *ve = new VarExp(Loc(), ifs->match);
ifs->condition = new CommaExp(ifs->loc, de, ve);
ifs->condition = ifs->condition->semantic(scd);
ifs->condition = semantic(ifs->condition, scd);

if (ifs->match->edtor)
{
Expand All @@ -1703,7 +1704,7 @@ class StatementSemanticVisitor : public Visitor
if (ifs->condition->op == TOKdotid)
((DotIdExp *)ifs->condition)->noderef = true;

ifs->condition = ifs->condition->semantic(sc);
ifs->condition = semantic(ifs->condition, sc);
ifs->condition = resolveProperties(sc, ifs->condition);
ifs->condition = ifs->condition->addDtorHook(sc);
}
Expand Down Expand Up @@ -1782,7 +1783,7 @@ class StatementSemanticVisitor : public Visitor
Expression *e = (*ps->args)[i];

sc = sc->startCTFE();
e = e->semantic(sc);
e = semantic(e, sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();
// pragma(msg) is allowed to contain types as well as expressions
Expand Down Expand Up @@ -1822,7 +1823,7 @@ class StatementSemanticVisitor : public Visitor
Expression *e = (*ps->args)[0];

sc = sc->startCTFE();
e = e->semantic(sc);
e = semantic(e, sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();

Expand Down Expand Up @@ -1854,7 +1855,7 @@ class StatementSemanticVisitor : public Visitor
Expression *e = (*ps->args)[0];

sc = sc->startCTFE();
e = e->semantic(sc);
e = semantic(e, sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();

Expand Down Expand Up @@ -1945,7 +1946,7 @@ class StatementSemanticVisitor : public Visitor
return;
}
bool conditionError = false;
ss->condition = ss->condition->semantic(sc);
ss->condition = semantic(ss->condition, sc);
ss->condition = resolveProperties(sc, ss->condition);
TypeEnum *te = NULL;
// preserve enum type for final switches
Expand Down Expand Up @@ -2105,7 +2106,7 @@ class StatementSemanticVisitor : public Visitor

//printf("CaseStatement::semantic() %s\n", cs->toChars());
sc = sc->startCTFE();
cs->exp = cs->exp->semantic(sc);
cs->exp = semantic(cs->exp, sc);
cs->exp = resolveProperties(sc, cs->exp);
sc = sc->endCTFE();
if (sw)
Expand Down Expand Up @@ -2217,14 +2218,14 @@ class StatementSemanticVisitor : public Visitor
}

sc = sc->startCTFE();
crs->first = crs->first->semantic(sc);
crs->first = semantic(crs->first, sc);
crs->first = resolveProperties(sc, crs->first);
sc = sc->endCTFE();
crs->first = crs->first->implicitCastTo(sc, sw->condition->type);
crs->first = crs->first->ctfeInterpret();

sc = sc->startCTFE();
crs->last = crs->last->semantic(sc);
crs->last = semantic(crs->last, sc);
crs->last = resolveProperties(sc, crs->last);
sc = sc->endCTFE();
crs->last = crs->last->implicitCastTo(sc, sw->condition->type);
Expand Down Expand Up @@ -2343,7 +2344,7 @@ class StatementSemanticVisitor : public Visitor

if (gcs->exp)
{
gcs->exp = gcs->exp->semantic(sc);
gcs->exp = semantic(gcs->exp, sc);
gcs->exp = gcs->exp->implicitCastTo(sc, sc->sw->condition->type);
gcs->exp = gcs->exp->optimize(WANTvalue);
if (gcs->exp->op == TOKerror)
Expand Down Expand Up @@ -2436,7 +2437,7 @@ class StatementSemanticVisitor : public Visitor
rs->exp = inferType(rs->exp, tret);
else if (fld && fld->treq)
rs->exp = inferType(rs->exp, fld->treq->nextOf()->nextOf());
rs->exp = rs->exp->semantic(sc);
rs->exp = semantic(rs->exp, sc);
rs->exp = resolveProperties(sc, rs->exp);
if (rs->exp->checkType())
rs->exp = new ErrorExp();
Expand Down Expand Up @@ -2467,7 +2468,7 @@ class StatementSemanticVisitor : public Visitor
errors = true;

rs->exp = new CastExp(rs->loc, rs->exp, Type::tvoid);
rs->exp = rs->exp->semantic(sc);
rs->exp = semantic(rs->exp, sc);
}

/* Replace:
Expand Down Expand Up @@ -2848,7 +2849,7 @@ class StatementSemanticVisitor : public Visitor
{
if (ss->exp)
{
ss->exp = ss->exp->semantic(sc);
ss->exp = semantic(ss->exp, sc);
ss->exp = resolveProperties(sc, ss->exp);
ss->exp = ss->exp->optimize(WANTvalue);
ss->exp = checkGC(sc, ss->exp);
Expand Down Expand Up @@ -2876,7 +2877,7 @@ class StatementSemanticVisitor : public Visitor
assert(t->ty == Tclass);

ss->exp = new CastExp(ss->loc, ss->exp, t);
ss->exp = ss->exp->semantic(sc);
ss->exp = semantic(ss->exp, sc);
}

#if 1
Expand Down Expand Up @@ -2937,14 +2938,14 @@ class StatementSemanticVisitor : public Visitor

FuncDeclaration *fdenter = FuncDeclaration::genCfunc(args, Type::tvoid, Id::criticalenter, STCnothrow);
Expression *e = new DotIdExp(ss->loc, new VarExp(ss->loc, tmp), Id::ptr);
e = e->semantic(sc);
e = semantic(e, sc);
e = new CallExp(ss->loc, new VarExp(ss->loc, fdenter, false), e);
e->type = Type::tvoid; // do not run semantic on e
cs->push(new ExpStatement(ss->loc, e));

FuncDeclaration *fdexit = FuncDeclaration::genCfunc(args, Type::tvoid, Id::criticalexit, STCnothrow);
e = new DotIdExp(ss->loc, new VarExp(ss->loc, tmp), Id::ptr);
e = e->semantic(sc);
e = semantic(e, sc);
e = new CallExp(ss->loc, new VarExp(ss->loc, fdexit, false), e);
e->type = Type::tvoid; // do not run semantic on e
Statement *s = new ExpStatement(ss->loc, e);
Expand Down Expand Up @@ -2972,7 +2973,7 @@ class StatementSemanticVisitor : public Visitor
Initializer *init;

//printf("WithStatement::semantic()\n");
ws->exp = ws->exp->semantic(sc);
ws->exp = semantic(ws->exp, sc);
ws->exp = resolveProperties(sc, ws->exp);
ws->exp = ws->exp->optimize(WANTvalue);
ws->exp = checkGC(sc, ws->exp);
Expand Down Expand Up @@ -3004,7 +3005,7 @@ class StatementSemanticVisitor : public Visitor
if (t->ty == Tpointer)
{
ws->exp = new PtrExp(ws->loc, ws->exp);
ws->exp = ws->exp->semantic(sc);
ws->exp = semantic(ws->exp, sc);
t = ws->exp->type->toBasetype();
}

Expand Down Expand Up @@ -3242,7 +3243,7 @@ class StatementSemanticVisitor : public Visitor
FuncDeclaration *fd = sc->parent->isFuncDeclaration();
fd->hasReturnExp |= 2;

ts->exp = ts->exp->semantic(sc);
ts->exp = semantic(ts->exp, sc);
ts->exp = resolveProperties(sc, ts->exp);
ts->exp = checkGC(sc, ts->exp);
if (ts->exp->op == TOKerror)
Expand Down Expand Up @@ -3353,7 +3354,7 @@ class StatementSemanticVisitor : public Visitor
void visit(ExtAsmStatement *s)
{
// Fold the instruction template string.
s->insn = s->insn->semantic(sc);
s->insn = semantic(s->insn, sc);
s->insn->ctfeInterpret();

if (s->insn->op != TOKstring || ((StringExp *) s->insn)->sz != 1)
Expand All @@ -3368,7 +3369,7 @@ class StatementSemanticVisitor : public Visitor
for (size_t i = 0; i < s->args->dim; i++)
{
Expression *e = (*s->args)[i];
e = e->semantic(sc);
e = semantic(e, sc);
// Check argument is a valid lvalue/rvalue.
if (i < s->outputargs)
e = e->modifiableLvalue(sc, NULL);
Expand All @@ -3377,7 +3378,7 @@ class StatementSemanticVisitor : public Visitor
(*s->args)[i] = e;

e = (*s->constraints)[i];
e = e->semantic(sc);
e = semantic(e, sc);
assert(e->op == TOKstring && ((StringExp *) e)->sz == 1);
(*s->constraints)[i] = e;
}
Expand All @@ -3389,7 +3390,7 @@ class StatementSemanticVisitor : public Visitor
for (size_t i = 0; i < s->clobbers->dim; i++)
{
Expression *e = (*s->clobbers)[i];
e = e->semantic(sc);
e = semantic(e, sc);
assert(e->op == TOKstring && ((StringExp *) e)->sz == 1);
(*s->clobbers)[i] = e;
}
Expand Down
5 changes: 3 additions & 2 deletions gcc/d/dfrontend/staticassert.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "template.h"
#include "declaration.h"

Expression *semantic(Expression *e, Scope *sc);

/********************************* AttribDeclaration ****************************/

Expand Down Expand Up @@ -57,7 +58,7 @@ void StaticAssert::semantic2(Scope *sc)
sc->flags |= SCOPEcondition;

sc = sc->startCTFE();
Expression *e = exp->semantic(sc);
Expression *e = ::semantic(exp, sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();
sc = sc->pop();
Expand All @@ -82,7 +83,7 @@ void StaticAssert::semantic2(Scope *sc)
if (msg)
{
sc = sc->startCTFE();
msg = msg->semantic(sc);
msg = ::semantic(msg, sc);
msg = resolveProperties(sc, msg);
sc = sc->endCTFE();
msg = msg->ctfeInterpret();
Expand Down
1 change: 1 addition & 0 deletions gcc/d/dfrontend/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// At present it is incomplete, but in future it should grow to contain
// most or all target machine and target O/S specific information.
#include "globals.h"
#include "tokens.h"

class ClassDeclaration;
class Dsymbol;
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/dfrontend/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
* http://www.boost.org/LICENSE_1_0.txt
* https://github.com/dlang/dmd/blob/master/src/lexer.h
* https://github.com/dlang/dmd/blob/master/src/tokens.h
*/

#ifndef DMD_TOKENS_H
Expand Down
40 changes: 22 additions & 18 deletions gcc/d/dfrontend/traits.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
int ScopeDsymbol_foreach(Scope *sc, Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn = NULL);
void freeFieldinit(Scope *sc);
Expression *resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads);
Expression *trySemantic(Expression *e, Scope *sc);
Expression *semantic(Expression *e, Scope *sc);


/************************************************
Expand Down Expand Up @@ -649,7 +652,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
}

StringExp *se = new StringExp(e->loc, (char *)id->toChars());
return se->semantic(sc);
return semantic(se, sc);
}
else if (e->ident == Id::getProtection)
{
Expand Down Expand Up @@ -677,7 +680,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
const char *protName = protectionToChars(s->prot().kind); // TODO: How about package(names)
assert(protName);
StringExp *se = new StringExp(e->loc, (char *) protName);
return se->semantic(sc);
return semantic(se, sc);
}
else if (e->ident == Id::parent)
{
Expand Down Expand Up @@ -706,19 +709,19 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
if (td->overroot) // if not start of overloaded list of TemplateDeclaration's
td = td->overroot; // then get the start
Expression *ex = new TemplateExp(e->loc, td, f);
ex = ex->semantic(sc);
ex = semantic(ex, sc);
return ex;
}

if (FuncLiteralDeclaration *fld = f->isFuncLiteralDeclaration())
{
// Directly translate to VarExp instead of FuncExp
Expression *ex = new VarExp(e->loc, fld, true);
return ex->semantic(sc);
return semantic(ex, sc);
}
}

return DsymbolExp::resolve(e->loc, sc, s, false);
return resolve(e->loc, sc, s, false);
}
else if (e->ident == Id::hasMember ||
e->ident == Id::getMember ||
Expand Down Expand Up @@ -783,7 +786,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
*/
Scope *scx = sc->push();
scx->flags |= SCOPEignoresymbolvisibility;
ex = ex->trySemantic(scx);
ex = trySemantic(ex, scx);
scx->pop();
return ex ? True(e) : False(e);
}
Expand All @@ -794,7 +797,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
((DotIdExp *)ex)->wantsym = true;
Scope *scx = sc->push();
scx->flags |= SCOPEignoresymbolvisibility;
ex = ex->semantic(scx);
ex = semantic(ex, scx);
scx->pop();
return ex;
}
Expand All @@ -806,7 +809,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
Expression *eorig = ex;
Scope *scx = sc->push();
scx->flags |= SCOPEignoresymbolvisibility;
ex = ex->semantic(scx);
ex = semantic(ex, scx);
if (errors < global.errors)
e->error("%s cannot be resolved", eorig->toChars());
//ex->print();
Expand Down Expand Up @@ -838,7 +841,8 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
p.ident = e->ident;
overloadApply(f, &p, &fptraits);

ex = (new TupleExp(e->loc, exps))->semantic(scx);
ex = new TupleExp(e->loc, exps);
ex = semantic(ex, scx);
scx->pop();
return ex;
}
Expand Down Expand Up @@ -888,7 +892,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
if (ad->aliasthis)
exps->push(new StringExp(e->loc, (char *)ad->aliasthis->ident->toChars()));
Expression *ex = new TupleExp(e->loc, exps);
ex = ex->semantic(sc);
ex = semantic(ex, sc);
return ex;
}
else if (e->ident == Id::getAttributes)
Expand Down Expand Up @@ -920,7 +924,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
UserAttributeDeclaration *udad = s->userAttribDecl;
Expressions *exps = udad ? udad->getAttributes() : new Expressions();
TupleExp *tup = new TupleExp(e->loc, exps);
return tup->semantic(sc);
return semantic(tup, sc);
}
else if (e->ident == Id::getFunctionAttributes)
{
Expand Down Expand Up @@ -961,7 +965,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
tf->attributesApply(&pa, &PushAttributes::fp, TRUSTformatSystem);

TupleExp *tup = new TupleExp(e->loc, mods);
return tup->semantic(sc);
return semantic(tup, sc);
}
else if (e->ident == Id::getFunctionVariadicStyle)
{
Expand Down Expand Up @@ -1017,7 +1021,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
assert(0);
}
StringExp *se = new StringExp(e->loc, (char*)style);
return se->semantic(sc);
return semantic(se, sc);
}
else if (e->ident == Id::getParameterStorageClasses)
{
Expand Down Expand Up @@ -1115,7 +1119,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
exps->push(new StringExp(e->loc, (char *)"scope"));

TupleExp *tup = new TupleExp(e->loc, exps);
return tup->semantic(sc);
return semantic(tup, sc);
}
else if (e->ident == Id::getLinkage)
{
Expand Down Expand Up @@ -1151,7 +1155,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
}
const char *linkage = linkageToChars(link);
StringExp *se = new StringExp(e->loc, (char *)linkage);
return se->semantic(sc);
return semantic(se, sc);
}
else if (e->ident == Id::allMembers ||
e->ident == Id::derivedMembers)
Expand Down Expand Up @@ -1277,7 +1281,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
* [ __traits(allMembers, ...) ]
*/
Expression *ex = new TupleExp(e->loc, exps);
ex = ex->semantic(sc);
ex = semantic(ex, sc);
return ex;
}
else if (e->ident == Id::compiles)
Expand Down Expand Up @@ -1315,7 +1319,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
}
if (ex)
{
ex = ex->semantic(sc2);
ex = semantic(ex, sc2);
ex = resolvePropertiesOnly(sc2, ex);
ex = ex->optimize(WANTvalue);
if (sc2->func && sc2->func->type->ty == Tfunction)
Expand Down Expand Up @@ -1427,7 +1431,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
collectUnitTests(sds->members, uniqueUnitTests, exps);
}
TupleExp *te= new TupleExp(e->loc, exps);
return te->semantic(sc);
return semantic(te, sc);
}
else if(e->ident == Id::getVirtualIndex)
{
Expand Down
6 changes: 6 additions & 0 deletions gcc/d/dfrontend/visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class CompoundStatement;
class CompoundDeclarationStatement;
class UnrolledLoopStatement;
class ScopeStatement;
class ForwardingStatement;
class WhileStatement;
class DoStatement;
class ForStatement;
class ForeachStatement;
class ForeachRangeStatement;
class StaticForeachStatement;
class IfStatement;
class ConditionalStatement;
class PragmaStatement;
Expand Down Expand Up @@ -106,6 +108,7 @@ class PragmaDeclaration;
class ConditionalDeclaration;
class StaticIfDeclaration;
class CompileDeclaration;
class StaticForeachDeclaration;
class UserAttributeDeclaration;

class ScopeDsymbol;
Expand Down Expand Up @@ -312,11 +315,13 @@ class Visitor
virtual void visit(CompoundDeclarationStatement *s) { visit((CompoundStatement *)s); }
virtual void visit(UnrolledLoopStatement *s) { visit((Statement *)s); }
virtual void visit(ScopeStatement *s) { visit((Statement *)s); }
virtual void visit(ForwardingStatement *s) { visit((Statement *)s); }
virtual void visit(WhileStatement *s) { visit((Statement *)s); }
virtual void visit(DoStatement *s) { visit((Statement *)s); }
virtual void visit(ForStatement *s) { visit((Statement *)s); }
virtual void visit(ForeachStatement *s) { visit((Statement *)s); }
virtual void visit(ForeachRangeStatement *s) { visit((Statement *)s); }
virtual void visit(StaticForeachStatement *s) { visit((Statement *)s); }
virtual void visit(IfStatement *s) { visit((Statement *)s); }
virtual void visit(ConditionalStatement *s) { visit((Statement *)s); }
virtual void visit(PragmaStatement *s) { visit((Statement *)s); }
Expand Down Expand Up @@ -395,6 +400,7 @@ class Visitor
virtual void visit(ConditionalDeclaration *s) { visit((AttribDeclaration *)s); }
virtual void visit(StaticIfDeclaration *s) { visit((ConditionalDeclaration *)s); }
virtual void visit(CompileDeclaration *s) { visit((AttribDeclaration *)s); }
virtual void visit(StaticForeachDeclaration *s) { visit((AttribDeclaration *)s); }
virtual void visit(UserAttributeDeclaration *s) { visit((AttribDeclaration *)s); }

virtual void visit(ScopeDsymbol *s) { visit((Dsymbol *)s); }
Expand Down
5 changes: 0 additions & 5 deletions gcc/testsuite/gdc.test/compilable/compile1.d
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,6 @@ mixin template Mix13481(void function() callback)
}
}

void sort13481() { int[] arr; arr.sort; }
mixin Mix13481!(&sort13481);

mixin Mix13481!({ int[] arr; arr.sort; });

/***************************************************/
// 13564

Expand Down
4 changes: 2 additions & 2 deletions gcc/testsuite/gdc.test/fail_compilation/fail9562.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PERMUTE_ARGS:
TEST_OUTPUT:
---
fail_compilation/fail9562.d(17): Error: int[] is not an expression
fail_compilation/fail9562.d(18): Error: int[] is not an expression
fail_compilation/fail9562.d(19): Error: int[] is not an expression
fail_compilation/fail9562.d(18): Error: no property 'reverse' for type 'int[]'
fail_compilation/fail9562.d(19): Error: no property 'sort' for type 'int[]'
fail_compilation/fail9562.d(20): Error: no property 'dup' for type 'int[]'
fail_compilation/fail9562.d(21): Error: no property 'idup' for type 'int[]'
---
Expand Down
462 changes: 0 additions & 462 deletions gcc/testsuite/gdc.test/runnable/stress.d

Large diffs are not rendered by default.

51 changes: 4 additions & 47 deletions gcc/testsuite/gdc.test/runnable/test12.d
Original file line number Diff line number Diff line change
Expand Up @@ -940,27 +940,28 @@ void test44()

/**************************************/

import std.algorithm;

struct Shell
{
string str;

const int opCmp(ref const Shell s)
{
import std.algorithm;
return std.algorithm.cmp(this.str, s.str);
}
}

void test45()
{
import std.algorithm;

Shell[3] a;

a[0].str = "hello";
a[1].str = "betty";
a[2].str = "fred";

a.sort;
a[].sort;

foreach (Shell s; a)
{
Expand Down Expand Up @@ -1150,48 +1151,6 @@ void writefln(string s)
printf("%.*s\n", s.length, s.ptr);
}

void test56()
{
string a = "abcd";
string r;

r = a.dup.reverse.idup;
writefln(r);
assert(r == "dcba");

a = "a\u1235\u1234c";
writefln(a);
r = a.dup.reverse.idup;
writefln(r);
assert(r == "c\u1234\u1235a");

a = "ab\u1234c";
writefln(a);
r = a.dup.reverse.idup;
writefln(r);
assert(r == "c\u1234ba");
}

/**************************************/

// DMD 0.114: Fixed .reverse bug of char[] and wchar[] with multibyte encodings.
void test57()
{
wstring a = "abcd";
wchar[] r;

r = a.dup.reverse;
assert(r == "dcba");

a = "a\U00012356\U00012346c";
r = a.dup.reverse;
assert(r == "c\U00012346\U00012356a");

a = "ab\U00012345c";
r = a.dup.reverse;
assert(r == "c\U00012345ba");
}

/**************************************/

void test58()
Expand Down Expand Up @@ -1282,8 +1241,6 @@ int main(string[] argv)
test53();
test54();
test55();
test56();
test57();
test58();
test59();

Expand Down
40 changes: 0 additions & 40 deletions gcc/testsuite/gdc.test/runnable/test20.d
Original file line number Diff line number Diff line change
Expand Up @@ -723,44 +723,6 @@ void test38()
}


/*****************************************/

void test39()
{
char[] a;
char[] r;

a = "abcd".dup;
r = a.reverse;
assert(r=="dcba");
assert(r.ptr==a.ptr);

a = "-\U000000A1\U00000901\U0000FFEE\U00010000\U000FFFFD_".dup;
r = a.reverse;
assert(r == "_\U000FFFFD\U00010000\U0000FFEE\U00000901\U000000A1-");
assert(a.ptr==r.ptr);
}

/*****************************************/

void test40()
{
wchar[] a;
wchar[] r;

a = "abcd"w.dup;
a = a.dup;
r = a.reverse;
assert(r=="dcba");
assert(r.ptr==a.ptr);

a = "-\U000000A1\U00000901\U0000FFEE\U00010000\U000FFFFD_"w.dup;
a = a.dup;
r = a.reverse;
assert(r == "_\U000FFFFD\U00010000\U0000FFEE\U00000901\U000000A1-");
assert(a.ptr==r.ptr);
}

/*****************************************/

void test41()
Expand Down Expand Up @@ -1305,8 +1267,6 @@ int main()
test36();
test37();
test38();
test39();
test40();
test41();
test42();
test43();
Expand Down
63 changes: 2 additions & 61 deletions gcc/testsuite/gdc.test/runnable/test4.d
Original file line number Diff line number Diff line change
Expand Up @@ -755,34 +755,6 @@ void test24()

/* ================================ */

void test25()
{
printf("test25()\n");
int a[10];

a[0] = 23;
a[1] = 1;
a[2] = 64;
a[3] = 5;
a[4] = 6;
a[5] = 5;
a[6] = 17;
a[7] = 3;
a[8] = 0;
a[9] = -1;

a.sort;

for (int i = 0; i < a.length - 1; i++)
{
//printf("i = %d", i);
//printf(" %d %d\n", a[i], a[i + 1]);
assert(a[i] <= a[i + 1]);
}
}

/* ================================ */

void test27()
{
static real[1] n = [ -1 ];
Expand Down Expand Up @@ -969,34 +941,6 @@ int test37()
}


/* ================================ */

void test38()
{
version (D_Bits)
{
bit a[];
a.length=3;
a[0]=false;
a[1]=true;
a[2]=false;

bit[] b=a.sort;

assert(a.length==3);
assert(!a[0]);
assert(!a[1]);
assert(a[2]);

assert(b.length==3);
assert(!b[0]);
assert(!b[1]);
assert(b[2]);

assert(&a != &b);
}
}

/* ================================ */

void test39()
Expand Down Expand Up @@ -1065,9 +1009,8 @@ void test41()

void test42()
{
real[10] array;
real[] copy = array.dup;
copy.sort;
real[10] array;
real[] copy = array.dup;
}

/* ================================ */
Expand Down Expand Up @@ -1530,7 +1473,6 @@ int main()
test22();
test23();
test24();
test25();
// test26();
test27();
// test28();
Expand All @@ -1543,7 +1485,6 @@ int main()
test35();
test36();
test37();
test38();
test39();
test40();
test41();
Expand Down
45 changes: 0 additions & 45 deletions gcc/testsuite/gdc.test/runnable/test5854.d

This file was deleted.

62 changes: 0 additions & 62 deletions gcc/testsuite/gdc.test/runnable/test8.d
Original file line number Diff line number Diff line change
Expand Up @@ -326,53 +326,6 @@ void test17()

/***********************************/

void test18()
{
string[] str;

str.length = 2;

version (none)
{
str[1] = "cba";
str[0] = "zyx";
}
else
{
str[1] = (cast(string)"cba").idup;
str[0] = (cast(string)"zyx").idup;
}

// This sorts the strs
str.sort;

// This will crash the compiler
str[0] = str[0].dup.sort.idup;

// This will give sintax error
//str[0].sort();

printf("%.*s", str[0].length, str[0].ptr);
printf("%.*s", str[1].length, str[1].ptr);
printf("\n");

string s = str[0] ~ str[1];
assert(s == "abczyx");
}

/***********************************/

void test19()
{
string array = "foobar";

array = array.idup;
array = array.dup.sort.idup;
assert(array == "abfoor");
}

/***********************************/



class A20
Expand Down Expand Up @@ -970,18 +923,6 @@ void test51()

/***********************************/

// Bug 391
void test52()
{
char[] a;
a = "\u3026\u2021\u3061\n".dup;
assert(a =="\u3026\u2021\u3061\n");
assert(a.sort == "\n\u2021\u3026\u3061");
assert(a.reverse =="\u3061\u3026\u2021\n");
}

/***********************************/

int main()
{
test1();
Expand All @@ -1001,8 +942,6 @@ int main()
test15();
test16();
test17();
test18();
test19();
test20();
test21();
test22();
Expand Down Expand Up @@ -1032,7 +971,6 @@ int main()
test49();
test50();
test51();
test52();

printf("Success\n");
return 0;
Expand Down
1 change: 0 additions & 1 deletion gcc/testsuite/gdc.test/runnable/ufcs.d
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ void test3()
assert("s" .init!string() == 1);

assert([1].sort!"a<b"() == 1);
assert([1].sort == [1]);

// templatized properties runs UFCS call.
assert(1024.max!"a<b" == 1);
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gdc.test/runnable/wc2.d
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main (string[] args)

printf("--------------------------------------\n");

foreach (string word1; dictionary.keys.sort)
foreach (string word1; dictionary.keys)
{
printf("%3d %.*s\n", dictionary[word1], word1.length, word1.ptr);
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gdc.test/runnable/wc3.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main (string[] args)

writefln("--------------------------------------");

foreach (word1; dictionary.keys.sort)
foreach (word1; dictionary.keys)
{
writefln("%3s %s", dictionary[word1], word1);
}
Expand Down