Merged last dmd2 changes

This commit is contained in:
Alexey Prokhin
2012-04-06 15:46:07 +04:00
9 changed files with 35 additions and 18 deletions

View File

@@ -453,6 +453,7 @@ void StorageClassDeclaration::setScope(Scope *sc)
if (stc & (STCsafe | STCtrusted | STCsystem))
scstc &= ~(STCsafe | STCtrusted | STCsystem);
scstc |= stc;
//printf("scstc = x%llx\n", scstc);
setScopeNewSc(sc, scstc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign);
}

View File

@@ -329,7 +329,7 @@ int Dsymbol::isAnonymous()
void Dsymbol::setScope(Scope *sc)
{
//printf("Dsymbol::setScope() %p %s\n", this, toChars());
//printf("Dsymbol::setScope() %p %s, %p stc = %llx\n", this, toChars(), sc, sc->stc);
if (!sc->nofree)
sc->setNoFree(); // may need it even after semantic() finishes
scope = sc;
@@ -1110,7 +1110,7 @@ static int dimDg(void *ctx, size_t n, Dsymbol *)
size_t ScopeDsymbol::dim(Dsymbols *members)
{
size_t n = 0;
foreach(members, &dimDg, &n);
foreach(NULL, members, &dimDg, &n);
return n;
}
#endif
@@ -1143,7 +1143,7 @@ static int getNthSymbolDg(void *ctx, size_t n, Dsymbol *sym)
Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
{
GetNthSymbolCtx ctx = { nth, NULL };
int res = foreach(members, &getNthSymbolDg, &ctx);
int res = foreach(NULL, members, &getNthSymbolDg, &ctx);
return res ? ctx.sym : NULL;
}
#endif
@@ -1158,7 +1158,7 @@ Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
*/
#if DMDV2
int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
int ScopeDsymbol::foreach(Scope *sc, Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
{
assert(dg);
if (!members)
@@ -1170,9 +1170,9 @@ int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *c
{ Dsymbol *s = (*members)[i];
if (AttribDeclaration *a = s->isAttribDeclaration())
result = foreach(a->include(NULL, NULL), dg, ctx, &n);
result = foreach(sc, a->include(sc, NULL), dg, ctx, &n);
else if (TemplateMixin *tm = s->isTemplateMixin())
result = foreach(tm->members, dg, ctx, &n);
result = foreach(sc, tm->members, dg, ctx, &n);
else if (s->isTemplateInstance())
;
else

View File

@@ -325,7 +325,7 @@ struct ScopeDsymbol : Dsymbol
static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL);
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
static int foreach(Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL);
static int foreach(Scope *sc, Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL);
ScopeDsymbol *isScopeDsymbol() { return this; }
};

View File

@@ -2981,7 +2981,7 @@ Lagain:
if (ti)
{ if (!ti->semanticRun)
ti->semantic(sc);
s = ti->inst->toAlias();
s = ti->toAlias();
if (!s->isTemplateInstance())
goto Lagain;
e = new ScopeExp(loc, ti);

View File

@@ -812,7 +812,14 @@ void Module::parse()
if (md)
{ this->ident = md->id;
this->safe = md->safe;
dst = Package::resolve(md->packages, &this->parent, NULL);
Package *ppack = NULL;
dst = Package::resolve(md->packages, &this->parent, &ppack);
if (ppack && ppack->isModule())
{
error(loc, "package name '%s' in file %s conflicts with usage as a module name in file %s",
ppack->toChars(), srcname, ppack->isModule()->srcfile->toChars());
dst = modules;
}
}
else
{
@@ -837,7 +844,7 @@ void Module::parse()
{
Package *pkg = prev->isPackage();
assert(pkg);
error(loc, "from file %s conflicts with package name %s",
error(pkg->loc, "from file %s conflicts with package name %s",
srcname, pkg->toChars());
}
}
@@ -1358,7 +1365,8 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package
#else
if (p->isModule())
{ // Return the module so that a nice error message can be generated
*ppkg = (Package *)p;
if (ppkg)
*ppkg = (Package *)p;
break;
}
#endif

View File

@@ -1360,8 +1360,11 @@ Type *Type::aliasthisOf()
// of errors which occured.
if (spec && global.errors != olderrs)
spec->errors = global.errors - olderrs;
tf = (TypeFunction *)fd->type;
}
t = ((TypeFunction *)fd->type)->next;
t = tf->next;
if (tf->isWild())
t = t->substWildTo(mod == 0 ? MODmutable : mod);
}
}
return t;

View File

@@ -4737,7 +4737,9 @@ Catch *Catch::syntaxCopy()
}
void Catch::semantic(Scope *sc)
{ ScopeDsymbol *sym;
{
if (type && type->deco)
return;
//printf("Catch::semantic(%s)\n", ident->toChars());
@@ -4754,7 +4756,7 @@ void Catch::semantic(Scope *sc)
}
#endif
sym = new ScopeDsymbol();
ScopeDsymbol *sym = new ScopeDsymbol();
sym->parent = sc->scopesym;
sc = sc->push(sym);

View File

@@ -477,8 +477,10 @@ void TemplateDeclaration::semantic(Scope *sc)
/* Remember Scope for later instantiations, but make
* a copy since attributes can change.
*/
this->scope = new Scope(*sc);
this->scope->setNoFree();
if (!this->scope)
{ this->scope = new Scope(*sc);
this->scope->setNoFree();
}
// Set up scope for parameters
ScopeDsymbol *paramsym = new ScopeDsymbol();

View File

@@ -396,7 +396,8 @@ Expression *TraitsExp::semantic(Scope *sc)
};
Identifiers *idents = new Identifiers;
ScopeDsymbol::foreach(sd->members, &PushIdentsDg::dg, idents);
ScopeDsymbol::foreach(sc, sd->members, &PushIdentsDg::dg, idents);
ClassDeclaration *cd = sd->isClassDeclaration();
if (cd && ident == Id::allMembers)
@@ -407,7 +408,7 @@ Expression *TraitsExp::semantic(Scope *sc)
{
for (size_t i = 0; i < cd->baseclasses->dim; i++)
{ ClassDeclaration *cb = (*cd->baseclasses)[i]->base;
ScopeDsymbol::foreach(cb->members, &PushIdentsDg::dg, idents);
ScopeDsymbol::foreach(NULL, cb->members, &PushIdentsDg::dg, idents);
if (cb->baseclasses->dim)
dg(cb, idents);
}