diff -uNr dmd-0.168/dmd/src/dmd/aggregate.h dmd-0.169/dmd/src/dmd/aggregate.h --- dmd-0.168/dmd/src/dmd/aggregate.h 2006-09-30 17:20:12.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/aggregate.h 2006-10-05 17:01:58.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -190,7 +191,7 @@ #define OFFSET_RUNTIME 0x76543210 virtual int isBaseOf(ClassDeclaration *cd, int *poffset); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc, Identifier *ident, int flags); FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); void interfaceSemantic(Scope *sc); int isNested(); diff -uNr dmd-0.168/dmd/src/dmd/arraytypes.h dmd-0.169/dmd/src/dmd/arraytypes.h --- dmd-0.168/dmd/src/dmd/arraytypes.h 2006-09-30 17:20:16.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/arraytypes.h 2006-10-05 17:06:06.000000000 +0200 @@ -1,3 +1,5 @@ + +// Compiler implementation of the D programming language // Copyright (c) 2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/attrib.h dmd-0.169/dmd/src/dmd/attrib.h --- dmd-0.168/dmd/src/dmd/attrib.h 2006-05-26 00:40:56.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/attrib.h 2006-10-05 17:04:38.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/class.c dmd-0.169/dmd/src/dmd/class.c --- dmd-0.168/dmd/src/dmd/class.c 2006-09-30 17:21:40.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/class.c 2006-10-07 19:05:22.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -79,6 +80,12 @@ Type::typeinfoclass = this; } + if (id == Id::TypeInfo_Interface) + { if (Type::typeinfointerface) + Type::typeinfointerface->error(msg); + Type::typeinfointerface = this; + } + if (id == Id::TypeInfo_Struct) { if (Type::typeinfostruct) Type::typeinfostruct->error(msg); @@ -488,7 +495,7 @@ /* Look for special member functions. * They must be in this class, not in a base class. */ - ctor = (CtorDeclaration *)search(Id::ctor, 0); + ctor = (CtorDeclaration *)search(0, Id::ctor, 0); if (ctor && ctor->toParent() != this) ctor = NULL; @@ -501,8 +508,8 @@ // inv = NULL; // Can be in base class - aggNew = (NewDeclaration *)search(Id::classNew, 0); - aggDelete = (DeleteDeclaration *)search(Id::classDelete, 0); + aggNew = (NewDeclaration *)search(0, Id::classNew, 0); + aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0); // If this class has no constructor, but base class does, create // a constructor: @@ -657,7 +664,7 @@ return 0; } -Dsymbol *ClassDeclaration::search(Identifier *ident, int flags) +Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags) { Dsymbol *s; @@ -671,7 +678,7 @@ return NULL; } - s = ScopeDsymbol::search(ident, flags); + s = ScopeDsymbol::search(loc, ident, flags); if (!s) { // Search bases classes in depth-first, left to right order @@ -688,7 +695,7 @@ error("base %s is forward referenced", b->base->ident->toChars()); else { - s = b->base->search(ident, flags); + s = b->base->search(loc, ident, flags); if (s == this) // happens if s is nested in this and derives from this s = NULL; else if (s) diff -uNr dmd-0.168/dmd/src/dmd/complex_t.h dmd-0.169/dmd/src/dmd/complex_t.h --- dmd-0.168/dmd/src/dmd/complex_t.h 2005-12-28 21:56:52.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/complex_t.h 2006-10-05 17:03:42.000000000 +0200 @@ -1,4 +1,6 @@ -// Copyright (c) 1999-2003 by Digital Mars + +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright and Burton Radons // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/cond.h dmd-0.169/dmd/src/dmd/cond.h --- dmd-0.168/dmd/src/dmd/cond.h 2005-12-12 16:04:48.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/cond.h 2006-10-05 17:03:18.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/declaration.c dmd-0.169/dmd/src/dmd/declaration.c --- dmd-0.168/dmd/src/dmd/declaration.c 2006-09-23 20:54:42.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/declaration.c 2006-10-07 19:13:38.000000000 +0200 @@ -307,7 +307,7 @@ { Identifier *id; id = (Identifier *)ti->idents.data[i]; - s = s->search(id, 0); + s = s->search(loc, id, 0); if (!s) // failed to find a symbol goto L1; // it must be a type s = s->toAlias(); @@ -317,7 +317,7 @@ } L1: if (overnext) - ScopeDsymbol::multiplyDefined(this, overnext); + ScopeDsymbol::multiplyDefined(0, this, overnext); type = type->semantic(loc, sc); this->inSemantic = 0; return; @@ -339,14 +339,14 @@ { FuncAliasDeclaration *fa = new FuncAliasDeclaration(f); if (!fa->overloadInsert(overnext)) - ScopeDsymbol::multiplyDefined(f, overnext); + ScopeDsymbol::multiplyDefined(0, f, overnext); overnext = NULL; s = fa; s->parent = sc->parent; } } if (overnext) - ScopeDsymbol::multiplyDefined(s, overnext); + ScopeDsymbol::multiplyDefined(0, s, overnext); if (s == this) { assert(global.errors); @@ -868,6 +868,11 @@ printf("parent = '%s'\n", parent->toChars()); #endif Dsymbol *parent = this->toParent(); + if (!parent && !(storage_class & (STCstatic | STCconst))) + { error("forward referenced"); + type = Type::terror; + return 0; + } return (storage_class & (STCstatic | STCconst) || parent->isModule() || parent->isTemplateInstance()); @@ -978,7 +983,7 @@ assert(linkage == LINKc); } -/***************************** TypeInfoStructDeclaration ***********************/ +/***************************** TypeInfoStructDeclaration **********************/ TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) : TypeInfoDeclaration(tinfo, 0) @@ -992,6 +997,13 @@ { } +/***************************** TypeInfoInterfaceDeclaration *******************/ + +TypeInfoInterfaceDeclaration::TypeInfoInterfaceDeclaration(Type *tinfo) + : TypeInfoDeclaration(tinfo, 0) +{ +} + /***************************** TypeInfoTypedefDeclaration *********************/ TypeInfoTypedefDeclaration::TypeInfoTypedefDeclaration(Type *tinfo) diff -uNr dmd-0.168/dmd/src/dmd/declaration.h dmd-0.169/dmd/src/dmd/declaration.h --- dmd-0.168/dmd/src/dmd/declaration.h 2006-08-28 12:37:00.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/declaration.h 2006-10-07 19:04:48.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -282,6 +283,13 @@ void toDt(dt_t **pdt); }; +struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration +{ + TypeInfoInterfaceDeclaration(Type *tinfo); + + void toDt(dt_t **pdt); +}; + struct TypeInfoTypedefDeclaration : TypeInfoDeclaration { TypeInfoTypedefDeclaration(Type *tinfo); diff -uNr dmd-0.168/dmd/src/dmd/doc.h dmd-0.169/dmd/src/dmd/doc.h --- dmd-0.168/dmd/src/dmd/doc.h 2005-09-17 00:37:04.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/doc.h 2006-10-05 17:02:56.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/dsymbol.c dmd-0.169/dmd/src/dmd/dsymbol.c --- dmd-0.168/dmd/src/dmd/dsymbol.c 2006-07-28 00:00:00.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/dsymbol.c 2006-10-05 17:00:58.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -232,7 +233,7 @@ // Most Dsymbols have no further semantic analysis needed } -Dsymbol *Dsymbol::search(Identifier *ident, int flags) +Dsymbol *Dsymbol::search(Loc loc, Identifier *ident, int flags) { //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); return NULL; @@ -331,7 +332,7 @@ s2 = sd->symtab->lookup(ident); if (!s2->overloadInsert(this)) { - sd->multiplyDefined(this, s2); + sd->multiplyDefined(0, this, s2); } } if (sd->isAggregateDeclaration() || sd->isEnumDeclaration()) @@ -529,7 +530,7 @@ return sd; } -Dsymbol *ScopeDsymbol::search(Identifier *ident, int flags) +Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags) { Dsymbol *s; int i; @@ -552,7 +553,7 @@ continue; //printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss->toChars(), prots[i], ss->isModule(), ss->isImport()); - s2 = ss->search(ident, ss->isModule() ? 1 : 0); + s2 = ss->search(loc, ident, ss->isModule() ? 1 : 0); if (!s) s = s2; else if (s2 && s != s2 && s->toAlias() != s2->toAlias()) @@ -562,9 +563,15 @@ */ Import *i1 = s->isImport(); Import *i2 = s2->isImport(); - if (!(i1 && i2 && i1->mod == i2->mod)) + if (!(i1 && i2 && + (i1->mod == i2->mod || + (!i1->parent->isImport() && !i2->parent->isImport() && + i1->ident->equals(i2->ident)) + ) + ) + ) { - ss->multiplyDefined(s, s2); + ss->multiplyDefined(loc, s, s2); break; } } @@ -622,23 +629,26 @@ ss->members = NULL; } -void ScopeDsymbol::multiplyDefined(Dsymbol *s1, Dsymbol *s2) +void ScopeDsymbol::multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2) { #if 0 printf("ScopeDsymbol::multiplyDefined()\n"); printf("s1 = %p, '%s' kind = '%s', parent = %s\n", s1, s1->toChars(), s1->kind(), s1->parent ? s1->parent->toChars() : ""); printf("s2 = %p, '%s' kind = '%s', parent = %s\n", s2, s2->toChars(), s2->kind(), s2->parent ? s2->parent->toChars() : ""); #endif -#if 1 - s1->error("conflicts with %s at %s", - s2->toPrettyChars(), - s2->locToChars()); -#else - s1->error("symbol %s conflicts with %s at %s", - s1->toPrettyChars(), - s2->toPrettyChars(), - s2->locToChars()); -#endif + if (loc.filename) + { ::error(loc, "%s at %s conflicts with %s at %s", + s1->toPrettyChars(), + s1->locToChars(), + s2->toPrettyChars(), + s2->locToChars()); + } + else + { + s1->error(loc, "conflicts with %s at %s", + s2->toPrettyChars(), + s2->locToChars()); + } //*(char*)0=0; } @@ -660,7 +670,7 @@ return sprev; } } - multiplyDefined(s, sprev); + multiplyDefined(0, s, sprev); return sprev; } @@ -678,10 +688,10 @@ this->withstate = withstate; } -Dsymbol *WithScopeSymbol::search(Identifier *ident, int flags) +Dsymbol *WithScopeSymbol::search(Loc loc, Identifier *ident, int flags) { // Acts as proxy to the with class declaration - return withstate->exp->type->toDsymbol(NULL)->search(ident, 0); + return withstate->exp->type->toDsymbol(NULL)->search(loc, ident, 0); } /****************************** ArrayScopeSymbol ******************************/ @@ -693,7 +703,7 @@ exp = e; } -Dsymbol *ArrayScopeSymbol::search(Identifier *ident, int flags) +Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags) { if (ident == Id::length || ident == Id::dollar) { VarDeclaration **pvar; diff -uNr dmd-0.168/dmd/src/dmd/dsymbol.h dmd-0.169/dmd/src/dmd/dsymbol.h --- dmd-0.168/dmd/src/dmd/dsymbol.h 2006-03-12 13:02:20.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/dsymbol.h 2006-10-05 17:00:48.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -118,7 +119,7 @@ virtual void semantic2(Scope *sc); virtual void semantic3(Scope *sc); virtual void inlineScan(); - virtual Dsymbol *search(Identifier *ident, int flags); + virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); virtual int overloadInsert(Dsymbol *s); #ifdef _DH char *toHChars(); @@ -212,11 +213,11 @@ ScopeDsymbol(); ScopeDsymbol(Identifier *id); Dsymbol *syntaxCopy(Dsymbol *s); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc loc, Identifier *ident, int flags); void importScope(ScopeDsymbol *s, enum PROT protection); int isforwardRef(); void defineRef(Dsymbol *s); - static void multiplyDefined(Dsymbol *s1, Dsymbol *s2); + static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2); Dsymbol *nameCollision(Dsymbol *s); char *kind(); @@ -232,7 +233,7 @@ WithStatement *withstate; WithScopeSymbol(WithStatement *withstate); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc loc, Identifier *ident, int flags); WithScopeSymbol *isWithScopeSymbol() { return this; } }; @@ -244,7 +245,7 @@ Expression *exp; // IndexExp or SliceExp ArrayScopeSymbol(Expression *e); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc loc, Identifier *ident, int flags); ArrayScopeSymbol *isArrayScopeSymbol() { return this; } }; diff -uNr dmd-0.168/dmd/src/dmd/enum.h dmd-0.169/dmd/src/dmd/enum.h --- dmd-0.168/dmd/src/dmd/enum.h 2006-02-08 20:15:34.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/enum.h 2006-10-05 17:03:52.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/expression.c dmd-0.169/dmd/src/dmd/expression.c --- dmd-0.168/dmd/src/dmd/expression.c 2006-09-14 16:20:54.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/expression.c 2006-10-07 15:38:06.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -768,6 +769,7 @@ else if (!loc.filename) loc = e->loc; error("%s is not an lvalue", e->toChars()); +*(char*)0=0; return this; } @@ -1496,7 +1498,7 @@ #if LOGSEMANTIC printf("IdentifierExp::semantic('%s')\n", ident->toChars()); #endif - s = sc->search(ident, &scopesym); + s = sc->search(loc, ident, &scopesym); if (s) { Expression *e; WithScopeSymbol *withsym; @@ -3724,7 +3726,7 @@ Dsymbol *s; ScopeExp *ie = (ScopeExp *)eright; - s = ie->sds->search(ident, 0); + s = ie->sds->search(loc, ident, 0); if (s) { s = s->toAlias(); @@ -4091,7 +4093,7 @@ assert(s); id = (Identifier *)ti->idents.data[0]; - s2 = s->search(id, 0); + s2 = s->search(loc, id, 0); if (!s2) { error("template identifier %s is not a member of %s", id->toChars(), s->ident->toChars()); goto Lerr; @@ -4686,6 +4688,14 @@ return 1; } +Expression *CallExp::toLvalue(Scope *sc, Expression *e) +{ + if (type->toBasetype()->ty == Tstruct) + return this; + else + return Expression::toLvalue(sc, e); +} + void CallExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { int i; @@ -7266,10 +7276,10 @@ e = new PtrExp(loc, this, type); e1 = e1->addressOf(sc); - e1 = e1->toLvalue(sc, NULL); + //e1 = e1->toLvalue(sc, NULL); e2 = e2->addressOf(sc); - e2 = e2->toLvalue(sc, NULL); + //e2 = e2->toLvalue(sc, NULL); typeCombine(sc); diff -uNr dmd-0.168/dmd/src/dmd/expression.h dmd-0.169/dmd/src/dmd/expression.h --- dmd-0.168/dmd/src/dmd/expression.h 2006-09-20 21:56:34.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/expression.h 2006-10-05 17:01:12.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -676,6 +677,7 @@ void toCBuffer(OutBuffer *buf, HdrGenState *hgs); elem *toElem(IRState *irs); void scanForNestedRef(Scope *sc); + Expression *toLvalue(Scope *sc, Expression *e); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); diff -uNr dmd-0.168/dmd/src/dmd/hdrgen.h dmd-0.169/dmd/src/dmd/hdrgen.h --- dmd-0.168/dmd/src/dmd/hdrgen.h 2006-03-08 11:32:22.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/hdrgen.h 2006-10-05 17:04:20.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // initial header generation implementation by Dave Fladebo // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/html.h dmd-0.169/dmd/src/dmd/html.h --- dmd-0.168/dmd/src/dmd/html.h 2006-09-25 13:13:58.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/html.h 2006-10-05 17:05:58.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/identifier.h dmd-0.169/dmd/src/dmd/identifier.h --- dmd-0.168/dmd/src/dmd/identifier.h 2005-12-12 01:53:32.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/identifier.h 2006-10-05 17:03:06.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/idgen.c dmd-0.169/dmd/src/dmd/idgen.c --- dmd-0.168/dmd/src/dmd/idgen.c 2006-09-29 14:24:38.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/idgen.c 2006-10-07 19:06:26.000000000 +0200 @@ -67,6 +67,7 @@ { "TypeInfo" }, { "TypeInfo_Class" }, + { "TypeInfo_Interface" }, { "TypeInfo_Struct" }, { "TypeInfo_Enum" }, { "TypeInfo_Typedef" }, diff -uNr dmd-0.168/dmd/src/dmd/import.c dmd-0.169/dmd/src/dmd/import.c --- dmd-0.168/dmd/src/dmd/import.c 2006-09-15 00:17:40.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/import.c 2006-10-05 17:01:54.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -143,7 +144,7 @@ { Dsymbol *s = (Dsymbol *)aliasdecls.data[i]; //printf("\tImport alias semantic('%s')\n", s->toChars()); - if (!mod->search((Identifier *)names.data[i], 0)) + if (!mod->search(loc, (Identifier *)names.data[i], 0)) error("%s not found", ((Identifier *)names.data[i])->toChars()); s->semantic(sc); @@ -216,7 +217,7 @@ return result; } -Dsymbol *Import::search(Identifier *ident, int flags) +Dsymbol *Import::search(Loc loc, Identifier *ident, int flags) { //printf("%s.Import::search(ident = '%s', flags = x%x)\n", toChars(), ident->toChars(), flags); @@ -224,7 +225,7 @@ load(); // Forward it to the package/module - return pkg->search(ident, flags); + return pkg->search(loc, ident, flags); } int Import::overloadInsert(Dsymbol *s) diff -uNr dmd-0.168/dmd/src/dmd/import.h dmd-0.169/dmd/src/dmd/import.h --- dmd-0.168/dmd/src/dmd/import.h 2006-07-17 00:42:16.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/import.h 2006-10-05 17:01:48.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -54,7 +55,7 @@ void semantic2(Scope *sc); Dsymbol *toAlias(); int addMember(Scope *sc, ScopeDsymbol *s, int memnum); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc loc, Identifier *ident, int flags); int overloadInsert(Dsymbol *s); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); diff -uNr dmd-0.168/dmd/src/dmd/init.c dmd-0.169/dmd/src/dmd/init.c --- dmd-0.168/dmd/src/dmd/init.c 2006-10-02 10:32:56.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/init.c 2006-10-07 01:46:32.000000000 +0200 @@ -165,7 +165,7 @@ else { //s = ad->symtab->lookup(id); - s = ad->search(id, 0); + s = ad->search(loc, id, 0); if (!s) { error("'%s' is not a member of '%s'", id->toChars(), t->toChars()); @@ -355,7 +355,7 @@ Lno: delete elements; - error("array initializers as expressions are not allowed"); + error(loc, "array initializers as expressions are not allowed"); return NULL; } diff -uNr dmd-0.168/dmd/src/dmd/init.h dmd-0.169/dmd/src/dmd/init.h --- dmd-0.168/dmd/src/dmd/init.h 2005-12-12 16:14:10.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/init.h 2006-10-05 17:03:32.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/lexer.h dmd-0.169/dmd/src/dmd/lexer.h --- dmd-0.168/dmd/src/dmd/lexer.h 2006-09-19 19:42:24.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/lexer.h 2006-10-05 17:05:40.000000000 +0200 @@ -1,5 +1,5 @@ - +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/macro.h dmd-0.169/dmd/src/dmd/macro.h --- dmd-0.168/dmd/src/dmd/macro.h 2006-04-05 09:37:00.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/macro.h 2006-10-05 17:04:30.000000000 +0200 @@ -1,4 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars + +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/mars.c dmd-0.169/dmd/src/dmd/mars.c --- dmd-0.168/dmd/src/dmd/mars.c 2006-09-28 12:44:48.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/mars.c 2006-10-05 17:00:04.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -58,7 +59,7 @@ copyright = "Copyright (c) 1999-2006 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.168"; + version = "v0.169"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -187,6 +188,7 @@ { Largs: error("missing or null command line arguments"); + fatal(); } for (i = 0; i < argc; i++) { diff -uNr dmd-0.168/dmd/src/dmd/mars.h dmd-0.169/dmd/src/dmd/mars.h --- dmd-0.168/dmd/src/dmd/mars.h 2006-06-15 01:17:38.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/mars.h 2006-10-05 17:00:36.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/module.c dmd-0.169/dmd/src/dmd/module.c --- dmd-0.168/dmd/src/dmd/module.c 2006-09-27 21:28:16.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/module.c 2006-10-05 17:01:44.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -122,14 +123,10 @@ else argobj = FileName::name(filename); if (!FileName::absolute(argobj)) - { //FileName::ensurePathExists(global.params.objdir); + { argobj = FileName::combine(global.params.objdir, argobj); } - char *p = FileName::path(argobj); - FileName::ensurePathExists(p); - mem.free(p); - if (global.params.objname) objfilename = new FileName(argobj, 0); else @@ -772,7 +769,7 @@ return needmoduleinfo || global.params.cov; } -Dsymbol *Module::search(Identifier *ident, int flags) +Dsymbol *Module::search(Loc loc, Identifier *ident, int flags) { /* Since modules can be circularly referenced, * need to stop infinite recursive searches. @@ -787,7 +784,7 @@ else { insearch = 1; - s = ScopeDsymbol::search(ident, flags); + s = ScopeDsymbol::search(loc, ident, flags); insearch = 0; searchCacheIdent = ident; diff -uNr dmd-0.168/dmd/src/dmd/module.h dmd-0.169/dmd/src/dmd/module.h --- dmd-0.168/dmd/src/dmd/module.h 2006-08-10 01:19:16.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/module.h 2006-10-05 17:01:40.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -123,7 +124,7 @@ void gensymfile(); void gendocfile(); int needModuleInfo(); - Dsymbol *search(Identifier *ident, int flags); + Dsymbol *search(Loc loc, Identifier *ident, int flags); void deleteObjFile(); void addDeferredSemantic(Dsymbol *s); void runDeferredSemantic(); diff -uNr dmd-0.168/dmd/src/dmd/mtype.c dmd-0.169/dmd/src/dmd/mtype.c --- dmd-0.168/dmd/src/dmd/mtype.c 2006-09-29 14:28:28.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/mtype.c 2006-10-07 19:06:04.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -79,6 +80,7 @@ ClassDeclaration *Type::typeinfo; ClassDeclaration *Type::typeinfoclass; +ClassDeclaration *Type::typeinfointerface; ClassDeclaration *Type::typeinfostruct; ClassDeclaration *Type::typeinfotypedef; ClassDeclaration *Type::typeinfopointer; @@ -1419,6 +1421,23 @@ e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } + else if (ident == Id::sort && (n->ty == Tchar || n->ty == Twchar)) + { + Expression *ec; + FuncDeclaration *fd; + Expressions *arguments; + char *nm; + static char *name[2] = { "_adSortChar", "_adSortWchar" }; + + nm = name[n->ty == Twchar]; + fd = FuncDeclaration::genCfunc(Type::tindex, nm); + ec = new VarExp(0, fd); + e = e->castTo(sc, n->arrayOf()); // convert to dynamic array + arguments = new Expressions(); + arguments->push(e); + e = new CallExp(e->loc, ec, arguments); + e->type = next->arrayOf(); + } else if (ident == Id::reverse || ident == Id::dup) { Expression *ec; @@ -2846,7 +2865,7 @@ TemplateDeclaration *td; TemplateInstance *ti = (TemplateInstance *)id; id = (Identifier *)ti->idents.data[0]; - sm = s->search(id, 0); + sm = s->search(loc, id, 0); if (!sm) { error(loc, "template identifier %s is not a member of %s", id->toChars(), s->toChars()); return; @@ -2864,7 +2883,7 @@ sm = ti->toAlias(); } else - sm = s->search(id, 0); + sm = s->search(loc, id, 0); //printf("\t3: s = '%s' %p, kind = '%s'\n",s->toChars(), s, s->kind()); //printf("getType = '%s'\n", s->getType()->toChars()); if (!sm) @@ -2895,7 +2914,7 @@ { sm = t->toDsymbol(sc); if (sm) - { sm = sm->search(id, 0); + { sm = sm->search(loc, id, 0); if (sm) goto L2; } @@ -2965,7 +2984,7 @@ si = s->isImport(); if (si) { - s = si->search(s->ident, 0); + s = si->search(loc, s->ident, 0); if (s && s != si) goto L1; s = si; @@ -3059,7 +3078,7 @@ Dsymbol *scopesym; //printf("TypeIdentifier::resolve(sc = %p, idents = '%s')\n", sc, toChars()); - s = sc->search(ident, &scopesym); + s = sc->search(loc, ident, &scopesym); resolveHelper(loc, sc, s, scopesym, pe, pt, ps); } @@ -3077,7 +3096,7 @@ if (!sc) return NULL; //printf("ident = '%s'\n", ident->toChars()); - s = sc->search(ident, &scopesym); + s = sc->search(loc, ident, &scopesym); if (s) { s = s->toAlias(); @@ -3094,7 +3113,7 @@ TemplateDeclaration *td; TemplateInstance *ti = (TemplateInstance *)id; id = (Identifier *)ti->idents.data[0]; - sm = s->search(id, 0); + sm = s->search(loc, id, 0); if (!sm) { error(loc, "template identifier %s is not a member of %s", id->toChars(), s->toChars()); break; @@ -3112,7 +3131,7 @@ sm = ti->toAlias(); } else - sm = s->search(id, 0); + sm = s->search(loc, id, 0); s = sm; if (!s) // failed to find a symbol @@ -3266,6 +3285,8 @@ Type *t; t = semantic(0, sc); + if (t == this) + return NULL; return t->toDsymbol(sc); } @@ -3288,7 +3309,9 @@ { Expression *e; Type *t; - //printf("TypeTypeof::semantic()\n"); + //printf("TypeTypeof::semantic() %p\n", this); + + //static int nest; if (++nest == 50) *(char*)0=0; /* Special case for typeof(this) and typeof(super) since both * should work even if they are not inside a non-static member function @@ -3849,13 +3872,13 @@ { ScopeExp *se = (ScopeExp *)de->e1; - s = se->sds->search(ident, 0); + s = se->sds->search(e->loc, ident, 0); e = de->e1; goto L1; } } - s = sym->search(ident, 0); + s = sym->search(e->loc, ident, 0); L1: if (!s) { @@ -4061,13 +4084,13 @@ { ScopeExp *se = (ScopeExp *)de->e1; - s = se->sds->search(ident, 0); + s = se->sds->search(e->loc, ident, 0); e = de->e1; goto L1; } } - s = sym->search(ident, 0); + s = sym->search(e->loc, ident, 0); L1: if (!s) { diff -uNr dmd-0.168/dmd/src/dmd/mtype.h dmd-0.169/dmd/src/dmd/mtype.h --- dmd-0.168/dmd/src/dmd/mtype.h 2006-09-28 21:11:10.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/mtype.h 2006-10-07 19:05:40.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -160,6 +161,7 @@ static ClassDeclaration *typeinfo; static ClassDeclaration *typeinfoclass; + static ClassDeclaration *typeinfointerface; static ClassDeclaration *typeinfostruct; static ClassDeclaration *typeinfotypedef; static ClassDeclaration *typeinfopointer; diff -uNr dmd-0.168/dmd/src/dmd/opover.c dmd-0.169/dmd/src/dmd/opover.c --- dmd-0.168/dmd/src/dmd/opover.c 2006-08-30 23:39:44.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/opover.c 2006-10-05 14:12:10.000000000 +0200 @@ -459,7 +459,7 @@ FuncDeclaration *fd; TemplateDeclaration *td; - s = ad->search(funcid, 0); + s = ad->search(0, funcid, 0); if (s) { Dsymbol *s2; diff -uNr dmd-0.168/dmd/src/dmd/optimize.c dmd-0.169/dmd/src/dmd/optimize.c --- dmd-0.168/dmd/src/dmd/optimize.c 2006-09-13 02:34:20.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/optimize.c 2006-10-07 15:36:34.000000000 +0200 @@ -566,24 +566,51 @@ ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1; ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2; + es1 = new ArrayLiteralExp(es1->loc, (Expressions *)es1->elements->copy()); es1->elements->insert(es1->elements->dim, es2->elements); e = es1; + + if (type->toBasetype()->ty == Tsarray) + { + e->type = new TypeSArray(e1->type->toBasetype()->next, new IntegerExp(0, es1->elements->dim, Type::tindex)); + e->type = e->type->semantic(loc, NULL); + } + else + e->type = type; } else if (e1->op == TOKarrayliteral && e1->type->toBasetype()->next->equals(e2->type)) { ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1; + es1 = new ArrayLiteralExp(es1->loc, (Expressions *)es1->elements->copy()); es1->elements->push(e2); e = es1; + + if (type->toBasetype()->ty == Tsarray) + { + e->type = new TypeSArray(e2->type, new IntegerExp(0, es1->elements->dim, Type::tindex)); + e->type = e->type->semantic(loc, NULL); + } + else + e->type = type; } else if (e2->op == TOKarrayliteral && e2->type->toBasetype()->next->equals(e1->type)) { ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2; + es2 = new ArrayLiteralExp(es2->loc, (Expressions *)es2->elements->copy()); es2->elements->shift(e1); e = es2; + + if (type->toBasetype()->ty == Tsarray) + { + e->type = new TypeSArray(e1->type, new IntegerExp(0, es2->elements->dim, Type::tindex)); + e->type = e->type->semantic(loc, NULL); + } + else + e->type = type; } else e = this; diff -uNr dmd-0.168/dmd/src/dmd/parse.h dmd-0.169/dmd/src/dmd/parse.h --- dmd-0.168/dmd/src/dmd/parse.h 2006-07-15 02:13:06.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/parse.h 2006-10-05 17:05:06.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/root.c dmd-0.169/dmd/src/dmd/root.c --- dmd-0.168/dmd/src/dmd/root.c 2006-06-17 22:23:36.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/root.c 2006-10-05 00:47:38.000000000 +0200 @@ -1086,6 +1086,7 @@ err2: close(fd); + ::remove(name); err: return 1; #endif @@ -1115,6 +1116,7 @@ err2: CloseHandle(h); + DeleteFileA(name); err: return 1; #endif diff -uNr dmd-0.168/dmd/src/dmd/scope.c dmd-0.169/dmd/src/dmd/scope.c --- dmd-0.168/dmd/src/dmd/scope.c 2006-07-14 16:19:28.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/scope.c 2006-10-05 14:02:46.000000000 +0200 @@ -187,7 +187,7 @@ } } -Dsymbol *Scope::search(Identifier *ident, Dsymbol **pscopesym) +Dsymbol *Scope::search(Loc loc, Identifier *ident, Dsymbol **pscopesym) { Dsymbol *s; Scope *sc; @@ -219,14 +219,14 @@ if (sc->scopesym) { //printf("\tlooking in scopesym '%s', kind = '%s'\n", sc->scopesym->toChars(), sc->scopesym->kind()); - s = sc->scopesym->search(ident, 0); + s = sc->scopesym->search(loc, ident, 0); if (s) { if (global.params.warnings && ident == Id::length && sc->scopesym->isArrayScopeSymbol() && sc->enclosing && - sc->enclosing->search(ident, NULL)) + sc->enclosing->search(loc, ident, NULL)) { fprintf(stdmsg, "warning - "); error("array 'length' hides other 'length' name in outer scope"); diff -uNr dmd-0.168/dmd/src/dmd/scope.h dmd-0.169/dmd/src/dmd/scope.h --- dmd-0.168/dmd/src/dmd/scope.h 2006-07-14 16:13:50.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/scope.h 2006-10-05 14:03:26.000000000 +0200 @@ -95,7 +95,7 @@ void mergeCallSuper(Loc loc, unsigned cs); - Dsymbol *search(Identifier *ident, Dsymbol **pscopesym); + Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym); Dsymbol *insert(Dsymbol *s); ClassDeclaration *getClassScope(); diff -uNr dmd-0.168/dmd/src/dmd/statement.c dmd-0.169/dmd/src/dmd/statement.c --- dmd-0.168/dmd/src/dmd/statement.c 2006-09-26 13:58:14.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/statement.c 2006-10-05 17:01:36.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/statement.h dmd-0.169/dmd/src/dmd/statement.h --- dmd-0.168/dmd/src/dmd/statement.h 2006-06-01 18:41:02.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/statement.h 2006-10-05 17:01:26.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/staticassert.h dmd-0.169/dmd/src/dmd/staticassert.h --- dmd-0.168/dmd/src/dmd/staticassert.h 2006-06-01 18:41:32.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/staticassert.h 2006-10-05 17:04:48.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/struct.c dmd-0.169/dmd/src/dmd/struct.c --- dmd-0.168/dmd/src/dmd/struct.c 2006-08-28 12:41:18.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/struct.c 2006-10-05 17:02:08.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -407,9 +408,9 @@ /* Look for special member functions. */ - inv = (InvariantDeclaration *)search(Id::classInvariant, 0); - aggNew = (NewDeclaration *)search(Id::classNew, 0); - aggDelete = (DeleteDeclaration *)search(Id::classDelete, 0); + inv = (InvariantDeclaration *)search(0, Id::classInvariant, 0); + aggNew = (NewDeclaration *)search(0, Id::classNew, 0); + aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0); if (sc->func) { diff -uNr dmd-0.168/dmd/src/dmd/template.c dmd-0.169/dmd/src/dmd/template.c --- dmd-0.168/dmd/src/dmd/template.c 2006-09-15 00:34:30.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/template.c 2006-10-07 01:41:30.000000000 +0200 @@ -91,6 +91,7 @@ this->parameters = parameters; this->members = decldefs; this->overnext = NULL; + this->overroot = NULL; this->scope = NULL; this->onemember = NULL; } @@ -233,7 +234,7 @@ ; } - + f->overroot = this; *pf = f; #if LOG printf("\ttrue: no conflict\n"); @@ -2140,6 +2141,10 @@ else { ea = isExpression((Object *)tiargs->data[j]); + if (!ea) + { assert(global.errors); + ea = new IntegerExp(0); + } assert(ea); ea = ea->semantic(sc); ea = ea->optimize(WANTvalue); @@ -2169,7 +2174,7 @@ int i; id = (Identifier *)idents.data[0]; - s = sc->search(id, &scopesym); + s = sc->search(loc, id, &scopesym); if (s) { #if LOG @@ -2182,7 +2187,7 @@ { Dsymbol *sm; id = (Identifier *)idents.data[i]; - sm = s->search(id, 0); + sm = s->search(loc, id, 0); if (!sm) { s = NULL; @@ -2226,6 +2231,8 @@ * of the template, if it has a !(arguments) */ tempdecl = ti->tempdecl; + if (tempdecl->overroot) // if not start of overloaded list of TemplateDeclaration's + tempdecl = tempdecl->overroot; // then get the start } else { @@ -2684,7 +2691,7 @@ if (semanticdone && // This for when a class/struct contains mixin members, and // is done over because of forward references - !toParent()->isAggregateDeclaration()) + parent && !toParent()->isAggregateDeclaration()) { #if LOG printf("\tsemantic done\n"); @@ -2720,7 +2727,7 @@ id = (Identifier *)idents->data[0]; if (id->dyncast() == DYNCAST_IDENTIFIER) { - s = sc->search(id, NULL); + s = sc->search(loc, id, NULL); } else { @@ -2739,7 +2746,7 @@ id = (Identifier *)idents->data[i]; if (id->dyncast() == DYNCAST_IDENTIFIER) { - sm = s->search(id, 0); + sm = s->search(loc, id, 0); } else { @@ -2748,7 +2755,7 @@ TemplateDeclaration *td; TemplateInstance *ti = (TemplateInstance *)id; id = (Identifier *)ti->idents.data[0]; - sm = s->search(id, 0); + sm = s->search(loc, id, 0); if (!sm) { error("template identifier %s is not a member of %s", id->toChars(), s->toChars()); return; diff -uNr dmd-0.168/dmd/src/dmd/template.h dmd-0.169/dmd/src/dmd/template.h --- dmd-0.168/dmd/src/dmd/template.h 2006-07-07 01:10:36.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/template.h 2006-10-06 16:41:20.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright @@ -40,6 +41,8 @@ Array instances; // array of TemplateInstance's TemplateDeclaration *overnext; // next overloaded TemplateDeclaration + TemplateDeclaration *overroot; // first in overnext list + Scope *scope; Dsymbol *onemember; // if !=NULL then one member of this template diff -uNr dmd-0.168/dmd/src/dmd/toobj.c dmd-0.169/dmd/src/dmd/toobj.c --- dmd-0.168/dmd/src/dmd/toobj.c 2006-10-01 01:54:44.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/toobj.c 2006-10-06 15:19:08.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2004 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -194,10 +194,15 @@ assert(!scope); // semantic() should have been run to completion - if (parent && parent->isTemplateInstance()) - scclass = SCcomdat; - else - scclass = SCglobal; + scclass = SCglobal; + for (Dsymbol *parent = this->parent; parent; parent = parent->parent) + { + if (parent->isTemplateInstance()) + { + scclass = SCcomdat; + break; + } + } // Put out the members for (i = 0; i < members->dim; i++) @@ -663,10 +668,15 @@ if (global.params.symdebug) toDebug(); - if (parent && parent->isTemplateInstance()) - scclass = SCcomdat; - else - scclass = SCglobal; + scclass = SCglobal; + for (Dsymbol *parent = this->parent; parent; parent = parent->parent) + { + if (parent->isTemplateInstance()) + { + scclass = SCcomdat; + break; + } + } // Put out the members for (i = 0; i < members->dim; i++) diff -uNr dmd-0.168/dmd/src/dmd/total.h dmd-0.169/dmd/src/dmd/total.h --- dmd-0.168/dmd/src/dmd/total.h 2006-03-07 18:52:50.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/total.h 2006-10-05 17:04:10.000000000 +0200 @@ -1,4 +1,5 @@ +// Compiler implementation of the D programming language // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright diff -uNr dmd-0.168/dmd/src/dmd/typinf.c dmd-0.169/dmd/src/dmd/typinf.c --- dmd-0.168/dmd/src/dmd/typinf.c 2006-09-26 13:39:42.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/typinf.c 2006-10-07 21:27:42.000000000 +0200 @@ -60,13 +60,20 @@ t = t->next->arrayOf(); // convert to corresponding dynamic array type break; + case Tclass: + if (((TypeClass *)t)->sym->isInterfaceDeclaration()) + break; + goto Linternal; + case Tarray: if (t->next->ty != Tclass) break; + goto Linternal; + case Tfunction: case Tdelegate: - case Tclass: case Tpointer: + Linternal: tid = internalTI[t->ty]; if (!tid) { tid = new TypeInfoDeclaration(t, 1); @@ -152,7 +159,10 @@ TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() { - return new TypeInfoClassDeclaration(this); + if (sym->isInterfaceDeclaration()) + return new TypeInfoInterfaceDeclaration(this); + else + return new TypeInfoClassDeclaration(this); } TypeInfoDeclaration *TypeEnum::getTypeInfoDeclaration() @@ -442,7 +452,7 @@ void TypeInfoClassDeclaration::toDt(dt_t **pdt) { - //printf("TypeInfoClassDeclaration::toDt()\n"); + //printf("TypeInfoClassDeclaration::toDt() %s\n", tinfo->toChars()); dtxoff(pdt, Type::typeinfoclass->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfoClass dtdword(pdt, 0); // monitor @@ -457,6 +467,23 @@ dtxoff(pdt, s, 0, TYnptr); // ClassInfo for tinfo } +void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt) +{ + //printf("TypeInfoInterfaceDeclaration::toDt() %s\n", tinfo->toChars()); + dtxoff(pdt, Type::typeinfointerface->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfoInterface + dtdword(pdt, 0); // monitor + + assert(tinfo->ty == Tclass); + + TypeClass *tc = (TypeClass *)tinfo; + Symbol *s; + + if (!tc->sym->vclassinfo) + tc->sym->vclassinfo = new ClassInfoDeclaration(tc->sym); + s = tc->sym->vclassinfo->toSymbol(); + dtxoff(pdt, s, 0, TYnptr); // ClassInfo for tinfo +} + void TypeInfoDeclaration::toObjFile() { Symbol *s; diff -uNr dmd-0.168/dmd/src/dmd/utf.h dmd-0.169/dmd/src/dmd/utf.h --- dmd-0.168/dmd/src/dmd/utf.h 2004-07-14 23:20:36.000000000 +0200 +++ dmd-0.169/dmd/src/dmd/utf.h 2006-10-05 17:02:46.000000000 +0200 @@ -1,5 +1,6 @@ +// Compiler implementation of the D programming language // utf.h -// Copyright (c) 2003 by Digital Mars +// Copyright (c) 2003-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/dmd/version.h dmd-0.169/dmd/src/dmd/version.h --- dmd-0.168/dmd/src/dmd/version.h 2006-02-27 23:26:26.000000000 +0100 +++ dmd-0.169/dmd/src/dmd/version.h 2006-10-05 17:04:02.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Compiler implementation of the D programming language +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr dmd-0.168/dmd/src/phobos/internal/adi.d dmd-0.169/dmd/src/phobos/internal/adi.d --- dmd-0.168/dmd/src/phobos/internal/adi.d 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/internal/adi.d 2006-10-08 01:06:30.000000000 +0200 @@ -33,7 +33,7 @@ import std.c.string; import std.string; import std.outofmemory; - +import std.utf; struct Array { @@ -52,6 +52,7 @@ if (a.length > 1) { char[6] tmp; + char[6] tmplo; char* lo = a.ptr; char* hi = &a[length - 1]; @@ -96,11 +97,11 @@ /* Shift the whole array. This is woefully inefficient */ - //writefln("stridelo = %d, stridehi = %d", stridelo, stridehi); memcpy(tmp, hi, stridehi); - memcpy(hi + stridehi - stridelo, lo, stridelo); + memcpy(tmplo, lo, stridelo); memmove(lo + stridehi, lo + stridelo , hi - (lo + stridelo)); memcpy(lo, tmp, stridehi); + memcpy(hi + stridehi - stridelo, tmplo, stridelo); lo += stridehi; hi = hi - 1 + (stridehi - stridelo); @@ -129,6 +130,10 @@ r = a.dup.reverse; //writefln(r); assert(r == "c\u1234ba"); + + a = "\u3026\u2021\u3061\n"; + r = a.dup.reverse; + assert(r == "\n\u3061\u2021\u3026"); } @@ -350,6 +355,50 @@ /********************************************** + * Sort array of chars. + */ + +extern (C) long _adSortChar(char[] a) +{ + if (a.length > 1) + { + dchar[] da = toUTF32(a); + da.sort; + size_t i = 0; + foreach (dchar d; da) + { char[4] buf; + char[] t = toUTF8(buf, d); + a[i .. i + t.length] = t[]; + i += t.length; + } + delete da; + } + return *cast(long*)(&a); +} + +/********************************************** + * Sort array of wchars. + */ + +extern (C) long _adSortWchar(wchar[] a) +{ + if (a.length > 1) + { + dchar[] da = toUTF32(a); + da.sort; + size_t i = 0; + foreach (dchar d; da) + { wchar[2] buf; + wchar[] t = toUTF16(buf, d); + a[i .. i + t.length] = t[]; + i += t.length; + } + delete da; + } + return *cast(long*)(&a); +} + +/********************************************** * Support for array.sort property for bit[]. */ diff -uNr dmd-0.168/dmd/src/phobos/internal/critical.c dmd-0.169/dmd/src/phobos/internal/critical.c --- dmd-0.168/dmd/src/phobos/internal/critical.c 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/internal/critical.c 2006-10-08 01:06:30.000000000 +0200 @@ -1,6 +1,8 @@ -// Copyright (C) 2000-2004 by Digital Mars, www.digitalmars.com -// All Rights Reserved -// Written by Walter Bright +/* + * Placed into the Public Domain + * written by Walter Bright, Digital Mars + * www.digitalmars.com + */ /* ================================= Win32 ============================ */ diff -uNr dmd-0.168/dmd/src/phobos/internal/mars.h dmd-0.169/dmd/src/phobos/internal/mars.h --- dmd-0.168/dmd/src/phobos/internal/mars.h 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/internal/mars.h 2006-10-08 01:06:30.000000000 +0200 @@ -1,10 +1,12 @@ /* * Placed into the Public Domain - * written by Walter Bright + * written by Walter Bright, Digital Mars * www.digitalmars.com */ +#include + #if __cplusplus extern "C" { #endif @@ -14,7 +16,7 @@ typedef struct Vtbl { - unsigned len; + size_t len; void **vptr; } Vtbl; @@ -28,22 +30,22 @@ typedef struct Object { void **vptr; - unsigned monitor; + void *monitor; } Object; typedef struct ClassInfo { Object object; - unsigned initlen; + size_t initlen; void *init; - unsigned namelen; + size_t namelen; char *name; Vtbl vtbl; - unsigned interfacelen; + size_t interfacelen; Interface *interfaces; struct ClassInfo *baseClass; @@ -58,7 +60,7 @@ { Object object; - unsigned msglen; + size_t msglen; char *msg; } Exception; diff -uNr dmd-0.168/dmd/src/phobos/internal/monitor.c dmd-0.169/dmd/src/phobos/internal/monitor.c --- dmd-0.168/dmd/src/phobos/internal/monitor.c 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/internal/monitor.c 2006-10-08 01:06:30.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (c) 2000-2004 by Digital Mars +// Copyright (c) 2000-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -47,7 +47,7 @@ EnterCriticalSection(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { - h->monitor = (unsigned)cs; + h->monitor = (void *)cs; InitializeCriticalSection(cs); cs = NULL; } @@ -130,7 +130,7 @@ pthread_mutex_lock(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { - h->monitor = (unsigned)cs; + h->monitor = (void *)cs; pthread_mutex_init(cs, & _monitors_attr); cs = NULL; } diff -uNr dmd-0.168/dmd/src/phobos/internal/object.d dmd-0.169/dmd/src/phobos/internal/object.d --- dmd-0.168/dmd/src/phobos/internal/object.d 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/internal/object.d 2006-10-08 01:06:30.000000000 +0200 @@ -495,6 +495,59 @@ ClassInfo info; } +class TypeInfo_Interface : TypeInfo +{ + char[] toString() { return info.name; } + + hash_t getHash(void *p) + { + Interface* pi = **cast(Interface ***)*cast(void**)p; + Object o = cast(Object)(*cast(void**)p - pi.offset); + assert(o); + return o.toHash(); + } + + int equals(void *p1, void *p2) + { + Interface* pi = **cast(Interface ***)*cast(void**)p1; + Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); + pi = **cast(Interface ***)*cast(void**)p2; + Object o2 = cast(Object)(*cast(void**)p2 - pi.offset); + + return o1 == o2 || (o1 && o1.opCmp(o2) == 0); + } + + int compare(void *p1, void *p2) + { + Interface* pi = **cast(Interface ***)*cast(void**)p1; + Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); + pi = **cast(Interface ***)*cast(void**)p2; + Object o2 = cast(Object)(*cast(void**)p2 - pi.offset); + int c = 0; + + // Regard null references as always being "less than" + if (o1 != o2) + { + if (o1) + { if (!o2) + c = 1; + else + c = o1.opCmp(o2); + } + else + c = -1; + } + return c; + } + + size_t tsize() + { + return Object.sizeof; + } + + ClassInfo info; +} + class TypeInfo_Struct : TypeInfo { char[] toString() { return name; } diff -uNr dmd-0.168/dmd/src/phobos/object.d dmd-0.169/dmd/src/phobos/object.d --- dmd-0.168/dmd/src/phobos/object.d 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/object.d 2006-10-08 01:06:30.000000000 +0200 @@ -100,6 +100,11 @@ ClassInfo info; } +class TypeInfo_Interface : TypeInfo +{ + ClassInfo info; +} + class TypeInfo_Struct : TypeInfo { char[] name; diff -uNr dmd-0.168/dmd/src/phobos/std/regexp.d dmd-0.169/dmd/src/phobos/std/regexp.d --- dmd-0.168/dmd/src/phobos/std/regexp.d 2006-10-02 16:06:18.000000000 +0200 +++ dmd-0.169/dmd/src/phobos/std/regexp.d 2006-10-08 01:06:30.000000000 +0200 @@ -140,6 +140,7 @@ import std.ctype; import std.outbuffer; import std.bitarray; + import std.utf; } /** Regular expression to extract an _email address */ @@ -1538,7 +1539,8 @@ goto Lnomatch; if (!(attributes & REA.dotmatchlf) && input[src] == cast(rchar)'\n') goto Lnomatch; - src++; + src += std.utf.stride(input, src); + //src++; pc++; break;