diff --git a/attrib.c b/attrib.c index 3970138b..326d9452 100644 --- a/attrib.c +++ b/attrib.c @@ -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); } diff --git a/dsymbol.c b/dsymbol.c index bc11a9b2..1f31ba86 100644 --- a/dsymbol.c +++ b/dsymbol.c @@ -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 diff --git a/dsymbol.h b/dsymbol.h index 3b66cde9..e1268e58 100644 --- a/dsymbol.h +++ b/dsymbol.h @@ -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; } }; diff --git a/expression.c b/expression.c index 266999f5..5831d39c 100644 --- a/expression.c +++ b/expression.c @@ -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); diff --git a/module.c b/module.c index a87d3a32..a09e22fd 100644 --- a/module.c +++ b/module.c @@ -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 diff --git a/mtype.c b/mtype.c index be554dd9..6c53c2e4 100644 --- a/mtype.c +++ b/mtype.c @@ -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; diff --git a/statement.c b/statement.c index 4cd42d5b..0a97f1b1 100644 --- a/statement.c +++ b/statement.c @@ -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); diff --git a/template.c b/template.c index d0563c0e..bf63e6e8 100644 --- a/template.c +++ b/template.c @@ -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(); diff --git a/traits.c b/traits.c index 2175f500..3ead0b45 100644 --- a/traits.c +++ b/traits.c @@ -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); } diff --git a/typinf.c b/typinf.c index 97bdc91a..167a5b1d 100644 --- a/typinf.c +++ b/typinf.c @@ -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++; } } }