Squashed 'dmd2/' changes from 3443f38..fc63fd3

fc63fd3 fix Issue 7843 - Regression(2.059 beta): Informational warning fails to produce executable
5947676 fix Issue 7820 - regression(DMD 2.059head) Wrong error on forward reference to 'front' with -property switch
8789ad7 fix Issue 7815 - Mixin template forward reference (?) regression
41ad039 Merge pull request #862 from 9rnsr/fix7814
05224bd Merge pull request #859 from 9rnsr/fix7812
3c74279 Merge pull request #857 from 9rnsr/fix7808
3b6c54f Merge pull request #864 from donc/regression7786
9afb367 Fix typo in error message for 7786
6acabc2 Fix issue 7786 dmd crashes with invalid module name
7df0068 fix Issue 7814 - ICE(tocsym.c) using scope(failure) within foreach-range
2bf1c32 fix Issue 7812 - Segfault on invalid code during template match deduction with errors gagged
a4f7070 fix Issue 7808 - Nullable's alias this does not work with structs containing classes

git-subtree-dir: dmd2
git-subtree-split: fc63fd36d82117947f360496dcb625af99c16133
This commit is contained in:
Alexey Prokhin
2012-04-06 15:45:52 +04:00
parent f2237662df
commit bfad290036
10 changed files with 37 additions and 19 deletions

View File

@@ -443,6 +443,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

@@ -312,7 +312,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;
@@ -1085,7 +1085,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
@@ -1118,7 +1118,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
@@ -1133,7 +1133,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)
@@ -1145,9 +1145,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

@@ -284,7 +284,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

@@ -2917,7 +2917,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

@@ -640,7 +640,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
{
@@ -665,7 +672,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());
}
}
@@ -1184,7 +1191,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

@@ -1298,8 +1298,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

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

View File

@@ -471,8 +471,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);
}

View File

@@ -596,7 +596,8 @@ void TypeInfoStructDeclaration::toDt(dt_t **pdt)
*/
if (!tf->isnothrow || tf->trust == TRUSTsystem || tf->purity == PUREimpure)
{ warning(fd->loc, "toHash() must be declared as extern (D) uint toHash() const pure nothrow @safe, not %s", tf->toChars());
global.errors++;
if (global.params.warnings == 1)
global.errors++;
}
}
}