diff -uNr dmd-1.010/dmd/src/dmd/access.c dmd-1.011/dmd/src/dmd/access.c --- dmd-1.010/dmd/src/dmd/access.c 2006-07-15 13:14:36.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/access.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/aggregate.h dmd-1.011/dmd/src/dmd/aggregate.h --- dmd-1.010/dmd/src/dmd/aggregate.h 2007-03-13 00:12:08.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/aggregate.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/arraytypes.h dmd-1.011/dmd/src/dmd/arraytypes.h --- dmd-1.010/dmd/src/dmd/arraytypes.h 2007-02-09 20:50:02.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/arraytypes.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 2006-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/attrib.c dmd-1.011/dmd/src/dmd/attrib.c --- dmd-1.010/dmd/src/dmd/attrib.c 2007-02-16 02:47:36.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/attrib.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/attrib.h dmd-1.011/dmd/src/dmd/attrib.h --- dmd-1.010/dmd/src/dmd/attrib.h 2007-02-04 01:45:04.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/attrib.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/bit.c dmd-1.011/dmd/src/dmd/bit.c --- dmd-1.010/dmd/src/dmd/bit.c 2004-01-17 01:32:46.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/bit.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2002 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/cast.c dmd-1.011/dmd/src/dmd/cast.c --- dmd-1.010/dmd/src/dmd/cast.c 2007-02-04 17:35:38.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/cast.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -898,7 +898,8 @@ Type *typeb = type->toBasetype(); Type *tb = t->toBasetype(); if ((tb->ty == Tarray || tb->ty == Tsarray) && - (typeb->ty == Tarray || typeb->ty == Tsarray)) + (typeb->ty == Tarray || typeb->ty == Tsarray) && + tb->next->toBasetype()->ty != Tvoid) { if (tb->ty == Tsarray) { TypeSArray *tsa = (TypeSArray *)tb; diff -uNr dmd-1.010/dmd/src/dmd/class.c dmd-1.011/dmd/src/dmd/class.c --- dmd-1.010/dmd/src/dmd/class.c 2007-03-13 00:01:54.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/class.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -394,6 +394,9 @@ if (baseClass) { + if (baseClass->storage_class & STCfinal) + error("cannot inherit from final class %s", baseClass->toChars()); + interfaces_dim--; interfaces++; @@ -481,7 +484,8 @@ isdeprecated = 1; sc = sc->push(this); - sc->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated); + sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic | + STCabstract | STCdeprecated); sc->parent = this; sc->inunion = 0; diff -uNr dmd-1.010/dmd/src/dmd/complex_t.h dmd-1.011/dmd/src/dmd/complex_t.h --- dmd-1.010/dmd/src/dmd/complex_t.h 2006-10-25 15:31:22.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/complex_t.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright and Burton Radons -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/cond.c dmd-1.011/dmd/src/dmd/cond.c --- dmd-1.010/dmd/src/dmd/cond.c 2007-02-16 02:44:46.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/cond.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/cond.h dmd-1.011/dmd/src/dmd/cond.h --- dmd-1.010/dmd/src/dmd/cond.h 2006-10-05 17:03:18.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/cond.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/constfold.c dmd-1.011/dmd/src/dmd/constfold.c --- dmd-1.010/dmd/src/dmd/constfold.c 2007-03-24 16:58:00.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/constfold.c 2007-04-10 18:46:12.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -1075,6 +1075,21 @@ e->type = type; } } + else if (e1->type->toBasetype()->ty == Tarray && e2->op == TOKint64) + { + uinteger_t i = e2->toInteger(); + + if (e1->op == TOKarrayliteral && !e1->checkSideEffect(2)) + { ArrayLiteralExp *ale = (ArrayLiteralExp *)e1; + if (i >= ale->elements->dim) + { e2->error("array index %ju is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim); + } + else + { e = (Expression *)ale->elements->data[i]; + e->type = type; + } + } + } return e; } diff -uNr dmd-1.010/dmd/src/dmd/declaration.c dmd-1.011/dmd/src/dmd/declaration.c --- dmd-1.010/dmd/src/dmd/declaration.c 2007-03-22 12:32:54.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/declaration.c 2007-04-10 18:20:50.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -136,9 +136,9 @@ buf.printf("_%s_%d", ident->toChars(), i); char *name = (char *)buf.extractData(); Identifier *id = new Identifier(name, TOKidentifier); - Argument *arg = new Argument(In, t, id, NULL); + Argument *arg = new Argument(STCin, t, id, NULL); #else - Argument *arg = new Argument(In, t, NULL, NULL); + Argument *arg = new Argument(STCin, t, NULL, NULL); #endif args->data[i] = (void *)arg; } @@ -371,50 +371,49 @@ // toAlias() will return aliasssym. Dsymbol *s; + Type *t; + Expression *e; - if (type->ty == Tident) - { - TypeIdentifier *ti = (TypeIdentifier *)type; + /* This section is needed because resolve() will: + * const x = 3; + * alias x y; + * try to alias y to 3. + */ + s = type->toDsymbol(sc); + if (s) + goto L2; // it's a symbolic alias - s = ti->toDsymbol(sc); - if (s) - goto L2; // it's a symbolic alias + //printf("alias type is %s\n", type->toChars()); + type->resolve(loc, sc, &e, &t, &s); + if (s) + { + goto L2; } - else if (type->ty == Tinstance) + else if (e) { - // Handle forms like: - // alias instance TFoo(int).bar.abc def; - - TypeInstance *ti = (TypeInstance *)type; - - s = ti->tempinst; - if (s) - { - s->semantic(sc); - s = s->toAlias(); - if (sc->parent->isFuncDeclaration()) - s->semantic2(sc); - - for (int i = 0; i < ti->idents.dim; i++) - { Identifier *id; - - id = (Identifier *)ti->idents.data[i]; - s = s->search(loc, id, 0); - if (!s) // failed to find a symbol - goto L1; // it must be a type - s = s->toAlias(); - } + // Try to convert Expression to Dsymbol + if (e->op == TOKvar) + { s = ((VarExp *)e)->var; goto L2; } + else if (e->op == TOKfunction) + { s = ((FuncExp *)e)->fd; + goto L2; + } + else + { error("cannot alias an expression %s", e->toChars()); + t = e->type; + } } - L1: + else if (t) + type = t; if (overnext) ScopeDsymbol::multiplyDefined(0, this, overnext); - type = type->semantic(loc, sc); this->inSemantic = 0; return; L2: + //printf("alias is a symbol %s %s\n", s->kind(), s->toChars()); type = NULL; VarDeclaration *v = s->isVarDeclaration(); if (v && v->linkage == LINKdefault) @@ -424,7 +423,7 @@ } else { - FuncDeclaration *f = s->isFuncDeclaration(); + FuncDeclaration *f = s->toAlias()->isFuncDeclaration(); if (f) { if (overnext) @@ -478,7 +477,7 @@ Dsymbol *AliasDeclaration::toAlias() { - //printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym->kind()); + //printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : ""); assert(this != aliassym); //static int count; if (++count == 10) *(char*)0=0; if (inSemantic) @@ -547,6 +546,7 @@ ctorinit = 0; aliassym = NULL; onstack = 0; + canassign = 0; value = NULL; } @@ -690,7 +690,7 @@ // Initialize by constructor only storage_class = (storage_class & ~STCconst) | STCctorinit; - if (isConst()) + if (isConst() || isFinal()) { } else if (isStatic()) @@ -750,9 +750,9 @@ if (type->isauto() && !noauto) { - if (storage_class & (STCfield | STCout | STCstatic) || !fd) + if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) { - error("globals, statics, fields, inout and out parameters cannot be auto"); + error("globals, statics, fields, ref and out parameters cannot be auto"); } if (!(storage_class & (STCauto | STCscope))) @@ -867,7 +867,10 @@ ei->exp = new CastExp(loc, ei->exp, type); } ei->exp = new AssignExp(loc, e1, ei->exp); + ei->exp->op = TOKconstruct; + canassign++; ei->exp = ei->exp->semantic(sc); + canassign--; ei->exp->optimize(WANTvalue); } else @@ -879,7 +882,7 @@ } } } - else if (isConst()) + else if (isConst() || isFinal()) { /* Because we may need the results of a const declaration in a * subsequent type, such as an array dimension, before semantic2() diff -uNr dmd-1.010/dmd/src/dmd/declaration.h dmd-1.011/dmd/src/dmd/declaration.h --- dmd-1.010/dmd/src/dmd/declaration.h 2007-03-07 00:37:02.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/declaration.h 2007-04-10 14:38:56.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -60,6 +60,8 @@ STCctorinit = 0x20000, // can only be set inside constructor STCtemplateparameter = 0x40000, // template parameter STCscope = 0x80000, // template parameter + STCinvariant = 0x100000, + STCref = 0x200000, }; struct Match @@ -110,7 +112,7 @@ int isIn() { return storage_class & STCin; } int isOut() { return storage_class & STCout; } - int isInOut() { return (storage_class & (STCin | STCout)) == (STCin | STCout); } + int isRef() { return storage_class & STCref; } enum PROT prot(); @@ -211,6 +213,7 @@ int ctorinit; // it has been initialized in a ctor int onstack; // 1: it has been allocated on the stack // 2: on stack, run destructor anyway + int canassign; // it can be assigned to Dsymbol *aliassym; // if redone as alias to another symbol Expression *value; // when interpreting, this is the value // (NULL if value not determinable) diff -uNr dmd-1.010/dmd/src/dmd/delegatize.c dmd-1.011/dmd/src/dmd/delegatize.c --- dmd-1.010/dmd/src/dmd/delegatize.c 2007-01-01 21:32:02.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/delegatize.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/doc.c dmd-1.011/dmd/src/dmd/doc.c --- dmd-1.010/dmd/src/dmd/doc.c 2007-03-22 12:56:32.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/doc.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/doc.h dmd-1.011/dmd/src/dmd/doc.h --- dmd-1.010/dmd/src/dmd/doc.h 2006-10-05 17:02:56.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/doc.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/dsymbol.c dmd-1.011/dmd/src/dmd/dsymbol.c --- dmd-1.010/dmd/src/dmd/dsymbol.c 2007-03-20 01:25:14.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/dsymbol.c 2007-04-10 23:41:06.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -27,6 +27,7 @@ #include "scope.h" #include "init.h" #include "import.h" +#include "template.h" /****************************** Dsymbol ******************************/ @@ -263,8 +264,57 @@ { //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); return NULL; -// error("%s.%s is undefined",toChars(), ident->toChars()); -// return this; +} + +/*************************************** + * Search for identifier id as a member of 'this'. + * id may be a template instance. + * Returns: + * symbol found, NULL if not + */ + +Dsymbol *Dsymbol::searchX(Loc loc, Scope *sc, Identifier *id) +{ + //printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); + Dsymbol *s = toAlias(); + Dsymbol *sm; + + switch (id->dyncast()) + { + case DYNCAST_IDENTIFIER: + sm = s->search(loc, id, 0); + break; + + case DYNCAST_DSYMBOL: + { // It's a template instance + //printf("\ttemplate instance id\n"); + Dsymbol *st = (Dsymbol *)id; + TemplateInstance *ti = st->isTemplateInstance(); + id = ti->name; + sm = s->search(loc, id, 0); + if (!sm) + { error("template identifier %s is not a member of %s %s", + id->toChars(), s->kind(), s->toChars()); + return NULL; + } + sm = sm->toAlias(); + TemplateDeclaration *td = sm->isTemplateDeclaration(); + if (!td) + { + error("%s is not a template, it is a %s", id->toChars(), sm->kind()); + return NULL; + } + ti->tempdecl = td; + if (!ti->semanticdone) + ti->semantic(sc); + sm = ti->toAlias(); + break; + } + + default: + assert(0); + } + return sm; } int Dsymbol::overloadInsert(Dsymbol *s) @@ -679,11 +729,11 @@ } else { - s1->error(loc, "conflicts with %s at %s", + s1->error(loc, "conflicts with %s %s at %s", + s2->kind(), s2->toPrettyChars(), s2->locToChars()); } -//*(char*)0=0; } Dsymbol *ScopeDsymbol::nameCollision(Dsymbol *s) diff -uNr dmd-1.010/dmd/src/dmd/dsymbol.h dmd-1.011/dmd/src/dmd/dsymbol.h --- dmd-1.010/dmd/src/dmd/dsymbol.h 2007-02-04 16:48:44.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/dsymbol.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -123,6 +123,7 @@ virtual void semantic3(Scope *sc); virtual void inlineScan(); virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); + Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); virtual int overloadInsert(Dsymbol *s); #ifdef _DH char *toHChars(); diff -uNr dmd-1.010/dmd/src/dmd/dump.c dmd-1.011/dmd/src/dmd/dump.c --- dmd-1.010/dmd/src/dmd/dump.c 2006-11-30 23:09:48.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/dump.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/entity.c dmd-1.011/dmd/src/dmd/entity.c --- dmd-1.010/dmd/src/dmd/entity.c 2006-02-12 23:13:30.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/entity.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/enum.c dmd-1.011/dmd/src/dmd/enum.c --- dmd-1.010/dmd/src/dmd/enum.c 2007-01-01 01:39:58.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/enum.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/enum.h dmd-1.011/dmd/src/dmd/enum.h --- dmd-1.010/dmd/src/dmd/enum.h 2006-10-05 17:03:52.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/enum.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/expression.c dmd-1.011/dmd/src/dmd/expression.c --- dmd-1.010/dmd/src/dmd/expression.c 2007-03-20 01:26:28.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/expression.c 2007-04-10 18:21:32.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -492,21 +492,16 @@ } L1: - if (!(p->inout == Lazy && p->type->ty == Tvoid)) + if (!(p->storageClass & STClazy && p->type->ty == Tvoid)) arg = arg->implicitCastTo(sc, p->type); - if (p->inout == Out || p->inout == InOut) + if (p->storageClass & (STCout | STCref)) { - // BUG: should check that argument to inout is type 'invariant' - // BUG: assignments to inout should also be type 'invariant' + // BUG: should check that argument to ref is type 'invariant' + // BUG: assignments to ref should also be type 'invariant' arg = arg->modifiableLvalue(sc, NULL); //if (arg->op == TOKslice) //arg->error("cannot modify slice %s", arg->toChars()); - - // Don't have a way yet to do a pointer to a bit in array - if (arg->op == TOKarray && - arg->type->toBasetype()->ty == Tbit) - error("cannot have out or inout argument of bit in array"); } // Convert static arrays to pointers @@ -517,7 +512,7 @@ } // Convert lazy argument to a delegate - if (p->inout == Lazy) + if (p->storageClass & STClazy) { arg = arg->toDelegate(sc, p->type); } @@ -1608,7 +1603,7 @@ if (ti && !ti->isTemplateMixin() && - (ti->idents.data[ti->idents.dim - 1] == f->ident || + (ti->name == f->ident || ti->toAlias()->ident == f->ident) && ti->tempdecl && ti->tempdecl->onemember) @@ -3202,8 +3197,9 @@ if (type && type->toBasetype()->ty == Tsarray) error("cannot change reference to static array '%s'", var->toChars()); - if (var->isConst()) - error("cannot modify const variable '%s'", var->toChars()); + VarDeclaration *v = var->isVarDeclaration(); + if (v && v->canassign == 0 && (var->isConst() || var->isFinal())) + error("cannot modify final variable '%s'", var->toChars()); if (var->isCtorinit()) { // It's only modifiable if inside the right constructor @@ -3694,7 +3690,7 @@ args->reserve(cd->baseclasses.dim); for (size_t i = 0; i < cd->baseclasses.dim; i++) { BaseClass *b = (BaseClass *)cd->baseclasses.data[i]; - args->push(new Argument(In, b->type, NULL, NULL)); + args->push(new Argument(STCin, b->type, NULL, NULL)); } tded = new TypeTuple(args); } @@ -3727,7 +3723,7 @@ for (size_t i = 0; i < dim; i++) { Argument *arg = Argument::getNth(params, i); assert(arg && arg->type); - args->push(new Argument(arg->inout, arg->type, NULL, NULL)); + args->push(new Argument(arg->storageClass, arg->type, NULL, NULL)); } tded = new TypeTuple(args); break; @@ -4037,12 +4033,13 @@ Expression *CompileExp::semantic(Scope *sc) { -#if LOGSEMANTIC +#if 1 || LOGSEMANTIC printf("CompileExp::semantic('%s')\n", toChars()); #endif UnaExp::semantic(sc); e1 = resolveProperties(sc, e1); e1 = e1->optimize(WANTvalue | WANTinterpret); +e1->print(); if (e1->op != TOKstring) { error("argument to mixin must be a string, not (%s)", e1->toChars()); return this; @@ -4725,7 +4722,7 @@ } assert(s); - id = (Identifier *)ti->idents.data[0]; + id = ti->name; s2 = s->search(loc, id, 0); if (!s2) { error("template identifier %s is not a member of %s %s", id->toChars(), s->kind(), s->ident->toChars()); @@ -5291,7 +5288,7 @@ { TemplateInstance *ti = f->parent->isTemplateInstance(); if (ti && - (ti->idents.data[ti->idents.dim - 1] == f->ident || + (ti->name == f->ident || ti->toAlias()->ident == f->ident) && ti->tempdecl) @@ -7308,8 +7305,13 @@ Expression *MulExp::semantic(Scope *sc) { Expression *e; +#if 0 + printf("MulExp::semantic() %s\n", toChars()); +#endif if (type) + { return this; + } BinExp::semanticp(sc); e = op_overload(sc); diff -uNr dmd-1.010/dmd/src/dmd/expression.h dmd-1.011/dmd/src/dmd/expression.h --- dmd-1.010/dmd/src/dmd/expression.h 2007-03-24 16:57:36.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/expression.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/func.c dmd-1.011/dmd/src/dmd/func.c --- dmd-1.010/dmd/src/dmd/func.c 2007-03-13 00:07:04.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/func.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -478,7 +478,7 @@ if (arg0->type->ty != Tarray || arg0->type->next->ty != Tarray || arg0->type->next->next->ty != Tchar || - (arg0->inout != None && arg0->inout != In)) + arg0->storageClass & (STCout | STCref | STClazy)) goto Lmainerr; break; } @@ -693,7 +693,7 @@ size_t dim = Argument::dim(t->arguments); for (size_t j = 0; j < dim; j++) { Argument *narg = Argument::getNth(t->arguments, j); - narg->inout = arg->inout; + narg->storageClass = arg->storageClass; } } } @@ -723,13 +723,9 @@ v->storage_class |= STCparameter; if (f->varargs == 2 && i + 1 == nparams) v->storage_class |= STCvariadic; - switch (arg->inout) - { case In: v->storage_class |= STCin; break; - case Out: v->storage_class |= STCout; break; - case InOut: v->storage_class |= STCin | STCout; break; - case Lazy: v->storage_class |= STCin | STClazy; break; - default: assert(0); - } + v->storage_class |= arg->storageClass & (STCin | STCout | STCref | STClazy); + if (v->storage_class & STClazy) + v->storage_class |= STCin; v->semantic(sc2); if (!sc2->insert(v)) error("parameter %s.%s is already defined", toChars(), v->toChars()); @@ -781,7 +777,7 @@ // BUG: need to error if accessing out parameters // BUG: need to treat parameters as const // BUG: need to disallow returns and throws - // BUG: verify that all in and inout parameters are read + // BUG: verify that all in and ref parameters are read frequire = frequire->semantic(sc2); labtab = NULL; // so body can't refer to labels } @@ -1029,7 +1025,7 @@ { VarDeclaration *v; v = (VarDeclaration *)parameters->data[i]; - if ((v->storage_class & (STCout | STCin)) == STCout) + if (v->storage_class & STCout) { assert(v->init); ExpInitializer *ie = v->init->isExpInitializer(); diff -uNr dmd-1.010/dmd/src/dmd/hdrgen.c dmd-1.011/dmd/src/dmd/hdrgen.c --- dmd-1.010/dmd/src/dmd/hdrgen.c 2006-11-09 02:14:20.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/hdrgen.c 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // Initial header generation implementation by Dave Fladebo -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/hdrgen.h dmd-1.011/dmd/src/dmd/hdrgen.h --- dmd-1.010/dmd/src/dmd/hdrgen.h 2006-10-05 17:04:20.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/hdrgen.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // initial header generation implementation by Dave Fladebo -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/html.c dmd-1.011/dmd/src/dmd/html.c --- dmd-1.010/dmd/src/dmd/html.c 2006-11-19 20:56:40.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/html.c 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/html.h dmd-1.011/dmd/src/dmd/html.h --- dmd-1.010/dmd/src/dmd/html.h 2006-10-25 15:31:48.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/html.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/identifier.c dmd-1.011/dmd/src/dmd/identifier.c --- dmd-1.010/dmd/src/dmd/identifier.c 2006-11-21 03:12:48.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/identifier.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/identifier.h dmd-1.011/dmd/src/dmd/identifier.h --- dmd-1.010/dmd/src/dmd/identifier.h 2006-11-21 03:13:00.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/identifier.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/idgen.c dmd-1.011/dmd/src/dmd/idgen.c --- dmd-1.010/dmd/src/dmd/idgen.c 2007-02-20 14:39:16.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/idgen.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/impcnvgen.c dmd-1.011/dmd/src/dmd/impcnvgen.c --- dmd-1.010/dmd/src/dmd/impcnvgen.c 2006-02-22 10:52:16.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/impcnvgen.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/import.c dmd-1.011/dmd/src/dmd/import.c --- dmd-1.010/dmd/src/dmd/import.c 2007-01-22 21:51:20.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/import.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/import.h dmd-1.011/dmd/src/dmd/import.h --- dmd-1.010/dmd/src/dmd/import.h 2007-01-22 21:47:20.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/import.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/inifile.c dmd-1.011/dmd/src/dmd/inifile.c --- dmd-1.010/dmd/src/dmd/inifile.c 2006-11-24 02:07:56.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/inifile.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com #include diff -uNr dmd-1.010/dmd/src/dmd/init.c dmd-1.011/dmd/src/dmd/init.c --- dmd-1.010/dmd/src/dmd/init.c 2007-03-11 00:54:22.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/init.c 2007-04-10 23:46:24.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -358,6 +358,7 @@ Expression *ArrayInitializer::toExpression() { Expressions *elements; + Expression *e; //printf("ArrayInitializer::toExpression()\n"); //static int i; if (++i == 2) halt(); @@ -374,7 +375,9 @@ goto Lno; elements->push(ex); } - return new ArrayLiteralExp(loc, elements); + e = new ArrayLiteralExp(loc, elements); + e->type = type; + return e; Lno: delete elements; diff -uNr dmd-1.010/dmd/src/dmd/init.h dmd-1.011/dmd/src/dmd/init.h --- dmd-1.010/dmd/src/dmd/init.h 2006-11-30 02:05:02.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/init.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/inline.c dmd-1.011/dmd/src/dmd/inline.c --- dmd-1.010/dmd/src/dmd/inline.c 2007-01-31 01:28:00.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/inline.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -1223,7 +1223,7 @@ for (int i = 0; i < parameters->dim; i++) { VarDeclaration *v = (VarDeclaration *)parameters->data[i]; - if (v->isOut() || v->type->toBasetype()->ty == Tsarray) + if (v->isOut() || v->isRef() || v->type->toBasetype()->ty == Tsarray) goto Lno; } } @@ -1322,7 +1322,7 @@ ei = new ExpInitializer(arg->loc, arg); vto = new VarDeclaration(vfrom->loc, vfrom->type, vfrom->ident, ei); - vto->storage_class |= vfrom->storage_class & (STCin | STCout | STClazy); + vto->storage_class |= vfrom->storage_class & (STCin | STCout | STClazy | STCref); vto->linkage = vfrom->linkage; vto->parent = iss->fd; //printf("vto = '%s', vto->storage_class = x%x\n", vto->toChars(), vto->storage_class); diff -uNr dmd-1.010/dmd/src/dmd/interpret.c dmd-1.011/dmd/src/dmd/interpret.c --- dmd-1.010/dmd/src/dmd/interpret.c 2007-03-24 16:57:46.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/interpret.c 2007-04-10 18:46:42.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -84,7 +84,7 @@ { size_t dim = Argument::dim(tf->parameters); for (size_t i = 0; i < dim; i++) { Argument *arg = Argument::getNth(tf->parameters, i); - if (arg->inout == Lazy) + if (arg->storageClass & STClazy) { cantInterpret = 1; return NULL; } @@ -111,9 +111,9 @@ #if LOG printf("arg[%d] = %s\n", i, earg->toChars()); #endif - if (arg->inout == Out || arg->inout == InOut) + if (arg->storageClass & (STCout | STCref)) { - /* Bind out or inout parameter to the corresponding + /* Bind out or ref parameter to the corresponding * variable v2 */ if (!istate || earg->op != TOKvar) @@ -388,7 +388,13 @@ START() if (!exp) return EXP_VOID_INTERPRET; +#if LOG + Expression *e = exp->interpret(istate); + printf("e = %p\n", e); + return e; +#else return exp->interpret(istate); +#endif } Expression *BreakStatement::interpret(InterState *istate) @@ -605,7 +611,7 @@ Expression *e = NULL; Expression *eaggr; - if (value->isOut()) + if (value->isOut() || value->isRef()) return EXP_CANT_INTERPRET; eaggr = aggr->interpret(istate); @@ -820,6 +826,9 @@ Expression *RealExp::interpret(InterState *istate) { +#if LOG + printf("RealExp::interpret() %s\n", toChars()); +#endif return this; } @@ -936,6 +945,9 @@ Expression *ArrayLiteralExp::interpret(InterState *istate) { Expressions *expsx = NULL; +#if LOG + printf("ArrayLiteralExp::interpret() %s\n", toChars()); +#endif if (elements) { for (size_t i = 0; i < elements->dim; i++) @@ -982,6 +994,9 @@ { Expression *e; Expression *e1; +#if LOG + printf("UnaExp::interpretCommon() %s\n", toChars()); +#endif e1 = this->e1->interpret(istate); if (e1 == EXP_CANT_INTERPRET) goto Lcant; @@ -1014,6 +1029,9 @@ Expression *e1; Expression *e2; +#if LOG + printf("BinExp::interpretCommon() %s\n", toChars()); +#endif e1 = this->e1->interpret(istate); if (e1 == EXP_CANT_INTERPRET) goto Lcant; @@ -1112,7 +1130,7 @@ VarDeclaration *v = ve->var->isVarDeclaration(); if (v && !v->isDataseg()) { - /* Chase down rebinding of out and inout + /* Chase down rebinding of out and ref */ if (v->value && v->value->op == TOKvar) { @@ -1181,6 +1199,9 @@ Expression *PostExp::interpret(InterState *istate) { +#if LOG + printf("PostExp::interpret() %s\n", toChars()); +#endif Expression *e = EXP_CANT_INTERPRET; if (e1->op == TOKvar) @@ -1189,7 +1210,7 @@ VarDeclaration *v = ve->var->isVarDeclaration(); if (v && !v->isDataseg()) { - /* Chase down rebinding of out and inout + /* Chase down rebinding of out and ref */ if (v->value && v->value->op == TOKvar) { @@ -1231,6 +1252,9 @@ Expression *AndAndExp::interpret(InterState *istate) { +#if LOG + printf("AndAndExp::interpret() %s\n", toChars()); +#endif Expression *e = e1->interpret(istate); if (e != EXP_CANT_INTERPRET) { @@ -1257,6 +1281,9 @@ Expression *OrOrExp::interpret(InterState *istate) { +#if LOG + printf("OrOrExp::interpret() %s\n", toChars()); +#endif Expression *e = e1->interpret(istate); if (e != EXP_CANT_INTERPRET) { @@ -1319,6 +1346,9 @@ Expression *CommaExp::interpret(InterState *istate) { +#if LOG + printf("CommaExp::interpret() %s\n", toChars()); +#endif Expression *e = e1->interpret(istate); if (e != EXP_CANT_INTERPRET) e = e2->interpret(istate); @@ -1327,6 +1357,9 @@ Expression *CondExp::interpret(InterState *istate) { +#if LOG + printf("CondExp::interpret() %s\n", toChars()); +#endif Expression *e = econd->interpret(istate); if (e != EXP_CANT_INTERPRET) { @@ -1459,6 +1492,9 @@ { Expression *e; Expression *e1; +#if LOG + printf("CastExp::interpret() %s\n", toChars()); +#endif e1 = this->e1->interpret(istate); if (e1 == EXP_CANT_INTERPRET) goto Lcant; @@ -1473,6 +1509,9 @@ { Expression *e; Expression *e1; +#if LOG + printf("AssertExp::interpret() %s\n", toChars()); +#endif e1 = this->e1->interpret(istate); if (e1 == EXP_CANT_INTERPRET) goto Lcant; diff -uNr dmd-1.010/dmd/src/dmd/lexer.c dmd-1.011/dmd/src/dmd/lexer.c --- dmd-1.010/dmd/src/dmd/lexer.c 2007-02-09 01:18:40.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/lexer.c 2007-04-10 21:35:40.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -2598,6 +2598,10 @@ { "invariant", TOKinvariant }, { "unittest", TOKunittest }, { "version", TOKversion }, + + // Added after 1.0 + { "ref", TOKref }, + { "macro", TOKmacro }, }; int Token::isKeyword() @@ -2614,10 +2618,14 @@ { StringValue *sv; unsigned u; enum TOK v; + unsigned nkeywords = sizeof(keywords) / sizeof(keywords[0]); + + if (global.params.Dversion == 1) + nkeywords -= 2; cmtable_init(); - for (u = 0; u < sizeof(keywords) / sizeof(keywords[0]); u++) + for (u = 0; u < nkeywords; u++) { char *s; //printf("keyword[%d] = '%s'\n",u, keywords[u].name); diff -uNr dmd-1.010/dmd/src/dmd/lexer.h dmd-1.011/dmd/src/dmd/lexer.h --- dmd-1.010/dmd/src/dmd/lexer.h 2007-02-09 01:18:24.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/lexer.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -146,6 +146,10 @@ // Testing TOKunittest, + // Added after 1.0 + TOKref, + TOKmacro, + TOKMAX }; diff -uNr dmd-1.010/dmd/src/dmd/link.c dmd-1.011/dmd/src/dmd/link.c --- dmd-1.010/dmd/src/dmd/link.c 2006-11-26 01:55:28.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/link.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/macro.c dmd-1.011/dmd/src/dmd/macro.c --- dmd-1.010/dmd/src/dmd/macro.c 2006-02-15 00:14:50.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/macro.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/macro.h dmd-1.011/dmd/src/dmd/macro.h --- dmd-1.010/dmd/src/dmd/macro.h 2006-10-05 17:04:30.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/macro.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/mangle.c dmd-1.011/dmd/src/dmd/mangle.c --- dmd-1.010/dmd/src/dmd/mangle.c 2007-03-09 21:57:42.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/mangle.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/mars.c dmd-1.011/dmd/src/dmd/mars.c --- dmd-1.010/dmd/src/dmd/mars.c 2007-03-11 22:00:34.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/mars.c 2007-04-10 18:26:18.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -60,7 +60,7 @@ copyright = "Copyright (c) 1999-2007 by Digital Mars"; written = "written by Walter Bright"; - version = "v1.010"; + version = "v1.011"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -150,7 +150,7 @@ printf("Digital Mars D Compiler %s\n%s %s\n", global.version, global.copyright, global.written); printf("\ -Documentation: www.digitalmars.com/d/index.html\n\ +Documentation: http://www.digitalmars.com/d/index.html\n\ Usage:\n\ dmd files.d ... { -switch }\n\ \n\ diff -uNr dmd-1.010/dmd/src/dmd/mars.h dmd-1.011/dmd/src/dmd/mars.h --- dmd-1.010/dmd/src/dmd/mars.h 2007-03-09 22:14:04.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/mars.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/module.c dmd-1.011/dmd/src/dmd/module.c --- dmd-1.010/dmd/src/dmd/module.c 2007-02-14 23:08:26.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/module.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/module.h dmd-1.011/dmd/src/dmd/module.h --- dmd-1.010/dmd/src/dmd/module.h 2007-01-22 21:49:26.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/module.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/mtype.c dmd-1.011/dmd/src/dmd/mtype.c --- dmd-1.010/dmd/src/dmd/mtype.c 2007-03-07 01:04:24.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/mtype.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -595,7 +595,7 @@ Loffset: if (v->storage_class & STCfield) { - e = new IntegerExp(e->loc, v->offset, Type::tint32); + e = new IntegerExp(e->loc, v->offset, Type::tsize_t); return e; } } @@ -1690,7 +1690,9 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) { + //printf("TypeSArray::resolve() %s\n", toChars()); next->resolve(loc, sc, pe, pt, ps); + //printf("s = %p, e = %p, t = %p\n", *ps, *pe, *pt); if (*pe) { // It's really an index expression Expression *e; @@ -1716,6 +1718,18 @@ { error(loc, "tuple index %ju exceeds %u", d, td->objects->dim); goto Ldefault; } + Object *o = (Object *)td->objects->data[(size_t)d]; + if (o->dyncast() == DYNCAST_DSYMBOL) + { + *ps = (Dsymbol *)o; + return; + } + if (o->dyncast() == DYNCAST_EXPRESSION) + { + *ps = NULL; + *pe = (Expression *)o; + return; + } /* Create a new TupleDeclaration which * is a slice [d..d+1] out of the old one. @@ -1724,7 +1738,7 @@ */ Objects *objects = new Objects; objects->setDim(1); - objects->data[0] = td->objects->data[(size_t)d]; + objects->data[0] = o; TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); *ps = tds; @@ -1750,7 +1764,7 @@ dim = semanticLength(sc, tbn, dim); - dim = dim->optimize(WANTvalue); + dim = dim->optimize(WANTvalue | WANTinterpret); integer_t d1 = dim->toInteger(); dim = dim->castTo(sc, tsize_t); dim = dim->optimize(WANTvalue); @@ -2108,7 +2122,7 @@ Type *TypeAArray::semantic(Loc loc, Scope *sc) { - //printf("TypeAArray::semantic() index->ty = %d\n", index->ty); + //printf("TypeAArray::semantic() %s index->ty = %d\n", toChars(), index->ty); // Deal with the case where we thought the index was a type, but // in reality it was an expression. @@ -2528,7 +2542,7 @@ if (!arg1->type->equals(arg2->type)) goto Ldistinct; - if (arg1->inout != arg2->inout) + if (arg1->storageClass != arg2->storageClass) inoutmismatch = 1; } } @@ -2697,12 +2711,12 @@ if (t->ty == Ttuple) dim = Argument::dim(parameters); - if (arg->inout != In) + if (arg->storageClass & (STCout | STCref | STClazy)) { if (t->ty == Tsarray) - error(loc, "cannot have out or inout parameter of type %s", t->toChars()); + error(loc, "cannot have out or ref parameter of type %s", t->toChars()); } - if (arg->inout != Lazy && t->ty == Tvoid) + if (!(arg->storageClass & STClazy) && t->ty == Tvoid) error(loc, "cannot have parameter of type %s", arg->type->toChars()); if (arg->defaultArg) @@ -2758,7 +2772,7 @@ { int m; Expression *arg; - // BUG: what about out and inout? + // BUG: what about out and ref? Argument *p = Argument::getNth(parameters, u); assert(p); @@ -2772,7 +2786,7 @@ } arg = (Expression *)args->data[u]; assert(arg); - if (p->inout == Lazy && p->type->ty == Tvoid && arg->type->ty != Tvoid) + if (p->storageClass & STClazy && p->type->ty == Tvoid && arg->type->ty != Tvoid) m = MATCHconvert; else m = arg->implicitConvTo(p->type); @@ -2990,11 +3004,12 @@ void TypeQualified::syntaxCopyHelper(TypeQualified *t) { + //printf("TypeQualified::syntaxCopyHelper(%s) %s\n", t->toChars(), toChars()); idents.setDim(t->idents.dim); for (int i = 0; i < idents.dim; i++) { Identifier *id = (Identifier *)t->idents.data[i]; - if (id->dyncast() != DYNCAST_IDENTIFIER) + if (id->dyncast() == DYNCAST_DSYMBOL) { TemplateInstance *ti = (TemplateInstance *)id; @@ -3020,7 +3035,7 @@ buf->writeByte('.'); - if (id->dyncast() != DYNCAST_IDENTIFIER) + if (id->dyncast() == DYNCAST_DSYMBOL) { TemplateInstance *ti = (TemplateInstance *)id; ti->toCBuffer(buf, hgs); @@ -3073,48 +3088,11 @@ { Dsymbol *sm; id = (Identifier *)idents.data[i]; - if (id->dyncast() != DYNCAST_IDENTIFIER) - { - // It's a template instance - //printf("\ttemplate instance id\n"); - TemplateDeclaration *td; - TemplateInstance *ti = (TemplateInstance *)id; - id = (Identifier *)ti->idents.data[0]; - sm = s->search(loc, id, 0); - if (!sm) - { -#ifdef DEBUG - printf("1: \n"); -#endif - error(loc, "template identifier %s is not a member of %s %s", - id->toChars(), s->kind(), s->toChars()); - return; - } - sm = sm->toAlias(); - td = sm->isTemplateDeclaration(); - if (!td) - { - error(loc, "%s is not a template", id->toChars()); - return; - } - ti->tempdecl = td; - if (!ti->semanticdone) - ti->semantic(sc); - sm = ti->toAlias(); - } - else - sm = s->search(loc, id, 0); + sm = s->searchX(loc, sc, id); //printf("\t3: s = '%s' %p, kind = '%s'\n",s->toChars(), s, s->kind()); //printf("getType = '%s'\n", s->getType()->toChars()); if (!sm) { -#if 0 - if (s->isAliasDeclaration() && this->ty == Tident) - { - *pt = this; - return; - } -#endif v = s->isVarDeclaration(); if (v && id == Id::length) { @@ -3139,7 +3117,9 @@ if (sm) goto L2; } - e = t->getProperty(loc, id); + //e = t->getProperty(loc, id); + e = new TypeExp(loc, t); + e = t->dotExp(sc, e, id); i++; L3: for (; i < idents.dim; i++) @@ -3313,66 +3293,19 @@ Dsymbol *TypeIdentifier::toDsymbol(Scope *sc) { - Dsymbol *s; - Dsymbol *scopesym; - //printf("TypeIdentifier::toDsymbol('%s')\n", toChars()); if (!sc) return NULL; //printf("ident = '%s'\n", ident->toChars()); - s = sc->search(loc, ident, &scopesym); + + Dsymbol *scopesym; + Dsymbol *s = sc->search(loc, ident, &scopesym); if (s) { for (int i = 0; i < idents.dim; i++) - { Identifier *id; - Dsymbol *sm; - - s = s->toAlias(); - id = (Identifier *)idents.data[i]; - //printf("\tid = '%s'\n", id->toChars()); - if (id->dyncast() != DYNCAST_IDENTIFIER) - { - // It's a template instance - //printf("\ttemplate instance id\n"); - TemplateDeclaration *td; - TemplateInstance *ti = (TemplateInstance *)id; - id = (Identifier *)ti->idents.data[0]; - sm = s->search(loc, id, 0); - if (!sm) - { - Type *t = s->getType(); - if (t) - sm = t->toDsymbol(sc); - if (!sm) - { -#ifdef DEBUG - printf("E2: %s\n", s->getType()->toChars()); -#endif - error(loc, "template identifier %s is not a member of %s %s", - id->toChars(), s->kind(), s->toChars()); - break; - } - sm = sm->toAlias(); - } - else - { - sm = sm->toAlias(); - td = sm->isTemplateDeclaration(); - if (!td) - { - error(loc, "%s %s is not a template", sm->kind(), id->toChars()); - break; - } - ti->tempdecl = td; - if (!ti->semanticdone) - ti->semantic(sc); - sm = ti->toAlias(); - } - } - else - sm = s->search(loc, id, 0); - s = sm; - + { + Identifier *id = (Identifier *)idents.data[i]; + s = s->searchX(loc, sc, id); if (!s) // failed to find a symbol { //printf("\tdidn't find a symbol\n"); break; @@ -3446,6 +3379,7 @@ Type *TypeInstance::syntaxCopy() { + //printf("TypeInstance::syntaxCopy() %s, %d\n", toChars(), idents.dim); TypeInstance *t; t = new TypeInstance(loc, (TemplateInstance *)tempinst->syntaxCopy(NULL)); @@ -3500,7 +3434,24 @@ Dsymbol *s; //printf("TypeInstance::semantic(%s)\n", toChars()); - resolve(loc, sc, &e, &t, &s); + + if (sc->parameterSpecialization) + { + unsigned errors = global.errors; + global.gag++; + + resolve(loc, sc, &e, &t, &s); + + global.gag--; + if (errors != global.errors) + { if (global.gag == 0) + global.errors = errors; + return this; + } + } + else + resolve(loc, sc, &e, &t, &s); + if (!t) { #ifdef DEBUG @@ -3623,8 +3574,26 @@ if (idents.dim) { - error(loc, ".property not implemented for typeof"); - goto Lerr; + Dsymbol *s = t->toDsymbol(sc); + for (size_t i = 0; i < idents.dim; i++) + { + if (!s) + break; + Identifier *id = (Identifier *)idents.data[i]; + s = s->searchX(loc, sc, id); + } + if (s) + { + t = s->getType(); + if (!t) + { error(loc, "%s is not a type", s->toChars()); + goto Lerr; + } + } + else + { error(loc, "cannot resolve .property for %s", toChars()); + goto Lerr; + } } return t; @@ -4722,7 +4691,7 @@ { Expression *e = (Expression *)exps->data[i]; if (e->type->ty == Ttuple) e->error("cannot form tuple of tuples"); - Argument *arg = new Argument(In, e->type, NULL, NULL); + Argument *arg = new Argument(STCin, e->type, NULL, NULL); arguments->data[i] = (void *)arg; } } @@ -4964,17 +4933,17 @@ /***************************** Argument *****************************/ -Argument::Argument(enum InOut inout, Type *type, Identifier *ident, Expression *defaultArg) +Argument::Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg) { this->type = type; this->ident = ident; - this->inout = inout; + this->storageClass = storageClass; this->defaultArg = defaultArg; } Argument *Argument::syntaxCopy() { - Argument *a = new Argument(inout, + Argument *a = new Argument(storageClass, type ? type->syntaxCopy() : NULL, ident, defaultArg ? defaultArg->syntaxCopy() : NULL); @@ -5044,11 +5013,12 @@ if (i) buf->writestring(", "); arg = (Argument *)arguments->data[i]; - if (arg->inout == Out) + if (arg->storageClass & STCout) buf->writestring("out "); - else if (arg->inout == InOut) - buf->writestring("inout "); - else if (arg->inout == Lazy) + else if (arg->storageClass & STCref) + buf->writestring((global.params.Dversion == 1) + ? (char *)"inout " : (char *)"ref "); + else if (arg->storageClass & STClazy) buf->writestring("lazy "); argbuf.reset(); arg->type->toCBuffer2(&argbuf, arg->ident, hgs); @@ -5117,16 +5087,17 @@ void Argument::toDecoBuffer(OutBuffer *buf) { - switch (inout) - { case In: + switch (storageClass & (STCin | STCout | STCref | STClazy)) + { case 0: + case STCin: break; - case Out: + case STCout: buf->writeByte('J'); break; - case InOut: + case STCref: buf->writeByte('K'); break; - case Lazy: + case STClazy: buf->writeByte('L'); break; default: diff -uNr dmd-1.010/dmd/src/dmd/mtype.h dmd-1.011/dmd/src/dmd/mtype.h --- dmd-1.010/dmd/src/dmd/mtype.h 2007-02-04 17:01:04.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/mtype.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -660,16 +660,17 @@ /**************************************************************/ -enum InOut { None, In, Out, InOut, Lazy }; +//enum InOut { None, In, Out, InOut, Lazy }; struct Argument : Object { - enum InOut inout; + //enum InOut inout; + unsigned storageClass; Type *type; Identifier *ident; Expression *defaultArg; - Argument(enum InOut inout, Type *type, Identifier *ident, Expression *defaultArg); + Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg); Argument *syntaxCopy(); Type *isLazyArray(); void toDecoBuffer(OutBuffer *buf); diff -uNr dmd-1.010/dmd/src/dmd/opover.c dmd-1.011/dmd/src/dmd/opover.c --- dmd-1.010/dmd/src/dmd/opover.c 2007-02-13 14:08:44.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/opover.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -567,7 +567,7 @@ #endif Lapply: { /* Look for an - * int opApply(int delegate(inout Type [, ...]) dg); + * int opApply(int delegate(ref Type [, ...]) dg); * overload */ Dsymbol *s = search_function(ad, diff -uNr dmd-1.010/dmd/src/dmd/optimize.c dmd-1.011/dmd/src/dmd/optimize.c --- dmd-1.010/dmd/src/dmd/optimize.c 2007-03-09 13:53:02.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/optimize.c 2007-04-10 18:19:42.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -48,11 +48,8 @@ VarDeclaration *v = ve->var->isVarDeclaration(); if (v && v->isConst() && v->init) { Expression *ei = v->init->toExpression(); - if (ei) - { e1 = ei; - if (!e1->type) - e1->type = v->type; - } + if (ei && ei->type) + e1 = ei; } } return e1; @@ -174,7 +171,8 @@ } if (e1->op == TOKvar) { VarExp *ve = (VarExp *)e1; - if (!ve->var->isOut() && !ve->var->isImportedSymbol()) + if (!ve->var->isOut() && !ve->var->isRef() && + !ve->var->isImportedSymbol()) { e = new SymOffExp(loc, ve->var, 0); e->type = type; diff -uNr dmd-1.010/dmd/src/dmd/parse.c dmd-1.011/dmd/src/dmd/parse.c --- dmd-1.010/dmd/src/dmd/parse.c 2007-02-18 02:32:16.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/parse.c 2007-04-10 21:34:32.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -191,7 +191,13 @@ break; case TOKinvariant: - s = parseInvariant(); + if (peek(&token)->value == TOKlcurly) + s = parseInvariant(); + else + { + stc = STCinvariant; + goto Lstc; + } break; case TOKunittest: @@ -261,6 +267,7 @@ case TOKabstract: stc |= STCabstract; goto Lstc; case TOKsynchronized: stc |= STCsynchronized; goto Lstc; case TOKdeprecated: stc |= STCdeprecated; goto Lstc; + case TOKinvariant: stc |= STCinvariant; goto Lstc; default: break; } @@ -271,17 +278,36 @@ if (token.value == TOKidentifier && peek(&token)->value == TOKassign) { - Identifier *ident = token.ident; - nextToken(); - nextToken(); - Initializer *init = parseInitializer(); - VarDeclaration *v = new VarDeclaration(loc, NULL, ident, init); - v->storage_class = stc; - s = v; - if (token.value != TOKsemicolon) - error("semicolon expected following auto declaration, not '%s'", token.toChars()); - else + while (1) + { + Identifier *ident = token.ident; nextToken(); + nextToken(); + Initializer *init = parseInitializer(); + VarDeclaration *v = new VarDeclaration(loc, NULL, ident, init); + v->storage_class = stc; + s = v; + if (token.value == TOKsemicolon) + { + nextToken(); + } + else if (token.value == TOKcomma) + { + nextToken(); + if (token.value == TOKidentifier && + peek(&token)->value == TOKassign) + { + decldefs->push(s); + addComment(s, comment); + continue; + } + else + error("Identifier expected following comma"); + } + else + error("semicolon expected following auto declaration, not '%s'", token.toChars()); + break; + } } else { a = parseBlock(); @@ -823,11 +849,11 @@ Identifier *ai; Type *at; Argument *a; - enum InOut inout; + unsigned storageClass; Expression *ae; ai = NULL; - inout = In; // parameter is "in" by default + storageClass = STCin; // parameter is "in" by default switch (token.value) { case TOKrparen: @@ -839,22 +865,23 @@ break; case TOKin: - inout = In; + storageClass = STCin; nextToken(); goto L1; case TOKout: - inout = Out; + storageClass = STCout; nextToken(); goto L1; case TOKinout: - inout = InOut; + case TOKref: + storageClass = STCref; nextToken(); goto L1; case TOKlazy: - inout = Lazy; + storageClass = STClazy; nextToken(); goto L1; @@ -878,15 +905,15 @@ * at ai ... */ - if (inout == Out || inout == InOut) - error("variadic argument cannot be out or inout"); + if (storageClass & (STCout | STCref)) + error("variadic argument cannot be out or ref"); varargs = 2; - a = new Argument(inout, at, ai, ae); + a = new Argument(storageClass, at, ai, ae); arguments->push(a); nextToken(); break; } - a = new Argument(inout, at, ai, ae); + a = new Argument(storageClass, at, ai, ae); arguments->push(a); if (token.value == TOKcomma) { nextToken(); @@ -1294,69 +1321,25 @@ return NULL; } -/************************************** - * Parse a TemplateInstance. - */ - -TemplateInstance *Parser::parseTemplateInstance() -{ - TemplateInstance *tempinst; - Identifier *id; - - //printf("parseTemplateInstance()\n"); - nextToken(); - if (token.value == TOKdot) - { - id = Id::empty; - } - else if (token.value == TOKidentifier) - { id = token.ident; - nextToken(); - } - else - { error("TemplateIdentifier expected following instance"); - goto Lerr; - } - tempinst = new TemplateInstance(loc, id); - while (token.value == TOKdot) - { nextToken(); - if (token.value == TOKidentifier) - tempinst->addIdent(token.ident); - else - { error("identifier expected following '.' instead of '%s'", token.toChars()); - goto Lerr; - } - nextToken(); - } - tempinst->tiargs = parseTemplateArgumentList(); - - if (1 || !global.params.useDeprecated) - error("instance is deprecated, use %s", tempinst->toChars()); - return tempinst; - -Lerr: - return NULL; -} - /****************************************** * Parse template mixin. * mixin Foo; * mixin Foo!(args); * mixin a.b.c!(args).Foo!(args); * mixin Foo!(args) identifier; + * mixin typeof(expr).identifier!(args); */ Dsymbol *Parser::parseMixin() { TemplateMixin *tm; Identifier *id; - TypeTypeof *tqual; + Type *tqual; Objects *tiargs; Array *idents; //printf("parseMixin()\n"); nextToken(); - tqual = NULL; if (token.value == TOKdot) { @@ -1939,7 +1922,7 @@ /* Look for auto initializers: * storage_class identifier = initializer; */ - if (storage_class && + while (storage_class && token.value == TOKidentifier && peek(&token)->value == TOKassign) { @@ -1955,6 +1938,16 @@ nextToken(); addComment(v, comment); } + else if (token.value == TOKcomma) + { + nextToken(); + if (!(token.value == TOKidentifier && peek(&token)->value == TOKassign)) + { + error("Identifier expected following comma"); + } + else + continue; + } else error("semicolon expected following auto declaration, not '%s'", token.toChars()); return a; @@ -2462,6 +2455,8 @@ case TOKconst: case TOKauto: case TOKextern: + case TOKfinal: + case TOKinvariant: // case TOKtypeof: Ldeclaration: { Array *a; @@ -2639,12 +2634,12 @@ Type *tb; Identifier *ai = NULL; Type *at; - enum InOut inout; + unsigned storageClass; Argument *a; - inout = In; - if (token.value == TOKinout) - { inout = InOut; + storageClass = STCin; + if (token.value == TOKinout || token.value == TOKref) + { storageClass = STCref; nextToken(); } if (token.value == TOKidentifier) @@ -2662,7 +2657,7 @@ if (!ai) error("no identifier for declarator %s", at->toChars()); Larg: - a = new Argument(inout, at, ai, NULL); + a = new Argument(storageClass, at, ai, NULL); arguments->push(a); if (token.value == TOKcomma) { nextToken(); @@ -2696,7 +2691,7 @@ Token *t = peek(&token); if (t->value == TOKassign) { - arg = new Argument(In, NULL, token.ident, NULL); + arg = new Argument(STCin, NULL, token.ident, NULL); nextToken(); nextToken(); } @@ -2719,7 +2714,7 @@ tb = parseBasicType(); at = parseDeclarator(tb, &ai); check(TOKassign); - arg = new Argument(In, at, ai, NULL); + arg = new Argument(STCin, at, ai, NULL); } // Check for " ident;" @@ -2728,7 +2723,7 @@ Token *t = peek(&token); if (t->value == TOKcomma || t->value == TOKsemicolon) { - arg = new Argument(In, NULL, token.ident, NULL); + arg = new Argument(STCin, NULL, token.ident, NULL); nextToken(); nextToken(); if (1 || !global.params.useDeprecated) @@ -3173,8 +3168,13 @@ void Parser::check(enum TOK value) { + check(loc, value); +} + +void Parser::check(Loc loc, enum TOK value) +{ if (token.value != value) - error("found '%s' when expecting '%s'", token.toChars(), Token::toChars(value)); + error(loc, "found '%s' when expecting '%s'", token.toChars(), Token::toChars(value)); nextToken(); } @@ -3451,6 +3451,8 @@ case TOKin: case TOKout: case TOKinout: + case TOKref: + case TOKlazy: t = peek(t); default: if (!isBasicType(&t)) @@ -3955,7 +3957,7 @@ // ( expression ) nextToken(); e = parseExpression(); - check(TOKrparen); + check(loc, TOKrparen); break; case TOKlbracket: diff -uNr dmd-1.010/dmd/src/dmd/parse.h dmd-1.011/dmd/src/dmd/parse.h --- dmd-1.010/dmd/src/dmd/parse.h 2007-02-18 02:30:20.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/parse.h 2007-04-10 21:34:32.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -69,7 +69,6 @@ Array *parseBlock(); TemplateDeclaration *parseTemplateDeclaration(); TemplateParameters *parseTemplateParameterList(); - TemplateInstance *parseTemplateInstance(); Dsymbol *parseMixin(); Objects *parseTemplateArgumentList(); StaticAssert *parseStaticAssert(); @@ -97,6 +96,7 @@ void parseContracts(FuncDeclaration *f); Statement *parseStatement(int flags); Initializer *parseInitializer(); + void check(Loc loc, enum TOK value); void check(enum TOK value); void check(enum TOK value, char *string); int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt); diff -uNr dmd-1.010/dmd/src/dmd/scope.c dmd-1.011/dmd/src/dmd/scope.c --- dmd-1.010/dmd/src/dmd/scope.c 2007-03-20 01:26:16.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/scope.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -64,6 +64,7 @@ this->nofree = 0; this->noctor = 0; this->intypeof = 0; + this->parameterSpecialization = 0; this->callSuper = 0; this->flags = 0; this->anonAgg = NULL; @@ -97,6 +98,7 @@ this->nofree = 0; this->noctor = enclosing->noctor; this->intypeof = enclosing->intypeof; + this->parameterSpecialization = enclosing->parameterSpecialization; this->callSuper = enclosing->callSuper; this->flags = 0; this->anonAgg = NULL; diff -uNr dmd-1.010/dmd/src/dmd/scope.h dmd-1.011/dmd/src/dmd/scope.h --- dmd-1.010/dmd/src/dmd/scope.h 2006-11-21 02:36:34.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/scope.h 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -54,6 +54,7 @@ int nofree; // set if shouldn't free it int noctor; // set if constructor calls aren't allowed int intypeof; // in typeof(exp) + int parameterSpecialization; // if in template parameter specialization unsigned callSuper; // primitive flow analysis for constructors #define CSXthis_ctor 1 // called this() diff -uNr dmd-1.010/dmd/src/dmd/statement.c dmd-1.011/dmd/src/dmd/statement.c --- dmd-1.010/dmd/src/dmd/statement.c 2007-03-19 16:34:16.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/statement.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -1159,8 +1159,8 @@ if (dim == 2) { // Declare key - if (arg->inout != In) - error("no storage class for %s", arg->ident->toChars()); + if (arg->storageClass & (STCout | STCref | STClazy)) + error("no storage class for key %s", arg->ident->toChars()); TY keyty = arg->type->ty; if ((keyty != Tint32 && keyty != Tuns32) || (global.params.isX86_64 && @@ -1177,8 +1177,8 @@ arg = (Argument *)arguments->data[1]; // value } // Declare value - if (arg->inout != In) - error("no storage class for %s", arg->ident->toChars()); + if (arg->storageClass & (STCout | STCref | STClazy)) + error("no storage class for value %s", arg->ident->toChars()); Dsymbol *var; if (te) { @@ -1251,12 +1251,12 @@ if (tnv->ty != tn->ty && (tnv->ty == Tchar || tnv->ty == Twchar || tnv->ty == Tdchar)) { - if (arg->inout == InOut) - error("foreach: value of UTF conversion cannot be inout"); + if (arg->storageClass & STCref) + error("foreach: value of UTF conversion cannot be ref"); if (dim == 2) { arg = (Argument *)arguments->data[0]; - if (arg->inout == InOut) - error("foreach: key cannot be inout"); + if (arg->storageClass & STCref) + error("foreach: key cannot be ref"); } goto Lapply; } @@ -1269,12 +1269,7 @@ var = new VarDeclaration(loc, arg->type, arg->ident, NULL); var->storage_class |= STCforeach; - switch (arg->inout) - { case In: var->storage_class |= STCin; break; - case Out: var->storage_class |= STCout; break; - case InOut: var->storage_class |= STCin | STCout; break; - default: assert(0); - } + var->storage_class |= arg->storageClass & (STCin | STCout | STCref); #if 1 DeclarationExp *de = new DeclarationExp(loc, var); de->semantic(sc); @@ -1314,8 +1309,8 @@ error("foreach: key type must be int or uint, not %s", key->type->toChars()); } - if (key && key->storage_class & STCout) - error("foreach: key cannot be out"); + if (key && key->storage_class & (STCout | STCref)) + error("foreach: key cannot be out or ref"); break; case Taarray: @@ -1362,17 +1357,17 @@ } /* Turn body into the function literal: - * int delegate(inout T arg) { body } + * int delegate(ref T arg) { body } */ args = new Arguments(); for (i = 0; i < dim; i++) { Argument *arg = (Argument *)arguments->data[i]; arg->type = arg->type->semantic(loc, sc); - if (arg->inout == InOut) + if (arg->storageClass & STCref) id = arg->ident; else - { // Make a copy of the inout argument so it isn't + { // Make a copy of the ref argument so it isn't // a reference. VarDeclaration *v; Initializer *ie; @@ -1386,7 +1381,7 @@ s = new DeclarationStatement(0, v); body = new CompoundStatement(loc, s, body); } - a = new Argument(InOut, arg->type, id, NULL); + a = new Argument(STCref, arg->type, id, NULL); args->push(a); } t = new TypeFunction(args, Type::tint32, 0, LINKd); @@ -1414,8 +1409,8 @@ Argument *arg = (Argument *)arguments->data[0]; if (dim == 2) { - if (arg->inout == InOut) - error("foreach: index cannot be inout"); + if (arg->storageClass & STCref) + error("foreach: index cannot be ref"); if (!arg->type->equals(taa->index)) error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars()); arg = (Argument *)arguments->data[1]; @@ -1585,8 +1580,9 @@ Argument *a = (Argument *)arguments->data[i]; if (i) buf->writestring(", "); - if (a->inout == InOut) - buf->writestring("inout "); + if (a->storageClass & STCref) + buf->writestring((global.params.Dversion == 1) + ? (char*)"inout " : (char*)"ref "); if (a->type) a->type->toCBuffer(buf, a->ident, hgs); else @@ -2115,7 +2111,7 @@ { int i; exp = exp->implicitCastTo(sc, sw->condition->type); - exp = exp->optimize(WANTvalue); + exp = exp->optimize(WANTvalue | WANTinterpret); if (exp->op != TOKstring && exp->op != TOKint64) { error("case must be a string or an integral constant, not %s", exp->toChars()); @@ -2421,7 +2417,7 @@ { VarExp *ve = (VarExp *)exp; VarDeclaration *v = ve->var->isVarDeclaration(); - if (!v || v->isOut()) + if (!v || v->isOut() || v->isRef()) fd->nrvo_can = 0; else if (fd->nrvo_var == NULL) { if (!v->isDataseg() && !v->isParameter() && v->toParent2() == fd) diff -uNr dmd-1.010/dmd/src/dmd/statement.h dmd-1.011/dmd/src/dmd/statement.h --- dmd-1.010/dmd/src/dmd/statement.h 2007-02-14 20:30:44.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/statement.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/staticassert.c dmd-1.011/dmd/src/dmd/staticassert.c --- dmd-1.010/dmd/src/dmd/staticassert.c 2007-03-07 11:37:38.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/staticassert.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/staticassert.h dmd-1.011/dmd/src/dmd/staticassert.h --- dmd-1.010/dmd/src/dmd/staticassert.h 2006-10-05 17:04:48.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/staticassert.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/struct.c dmd-1.011/dmd/src/dmd/struct.c --- dmd-1.010/dmd/src/dmd/struct.c 2007-01-26 00:47:40.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/struct.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -301,7 +301,7 @@ TypeFunction *tfeqptr; { Arguments *arguments = new Arguments; - Argument *arg = new Argument(In, handle, Id::p, NULL); + Argument *arg = new Argument(STCin, handle, Id::p, NULL); arguments->push(arg); tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd); @@ -311,7 +311,7 @@ TypeFunction *tfeq; { Arguments *arguments = new Arguments; - Argument *arg = new Argument(In, type, NULL, NULL); + Argument *arg = new Argument(STCin, type, NULL, NULL); arguments->push(arg); tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd); diff -uNr dmd-1.010/dmd/src/dmd/template.c dmd-1.011/dmd/src/dmd/template.c --- dmd-1.010/dmd/src/dmd/template.c 2007-03-20 03:38:58.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/template.c 2007-04-10 23:11:26.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -247,6 +247,7 @@ ScopeDsymbol *paramsym = new ScopeDsymbol(); paramsym->parent = sc->parent; Scope *paramscope = sc->push(paramsym); + paramscope->parameterSpecialization = 1; for (int i = 0; i < parameters->dim; i++) { @@ -308,6 +309,7 @@ TemplateDeclaration *pthis = this; for (pf = &pthis; *pf; pf = &(*pf)->overnext) { +#if 0 // Conflict if TemplateParameter's match // Will get caught anyway later with TemplateInstance, but // should check it now. @@ -331,6 +333,7 @@ Lcontinue: ; +#endif } f->overroot = this; @@ -409,7 +412,10 @@ m2 = tp->matchArg(paramscope, ti->tiargs, i, parameters, dedtypes, &sparam); if (m2 == MATCHnomatch) - { //printf("\tmatchArg() for parameter %i failed\n", i); + { +#if 0 + printf("\tmatchArg() for parameter %i failed\n", i); +#endif goto Lnomatch; } @@ -701,8 +707,13 @@ } else { farg = (Expression *)fargs->data[i]; +#if 0 + printf("farg->type = %s\n", farg->type->toChars()); + printf("fparam->type = %s\n", fparam->type->toChars()); +#endif + m = farg->type->deduceType(scope, fparam->type, parameters, &dedtypes); - //printf("\tm = %d\n", m); + //printf("\tdeduceType m = %d\n", m); /* If no match, see if there's a conversion to a delegate */ @@ -961,7 +972,7 @@ } if (td_ambig) { - error(loc, "%s matches more than one template declaration, %s and %s", + error(loc, "%s matches more than one function template declaration, %s and %s", toChars(), td_best->toChars(), td_ambig->toChars()); } @@ -1317,7 +1328,7 @@ { Argument *a = Argument::getNth(this->parameters, i); Argument *ap = Argument::getNth(tp->parameters, i); - if (a->inout != ap->inout || + if (a->storageClass != ap->storageClass || !a->type->deduceType(sc, ap->type, parameters, dedtypes)) return MATCHnomatch; } @@ -1348,7 +1359,7 @@ Type *tparam, TemplateParameters *parameters, Objects *dedtypes) { - //printf("TypeInstance::deduceType()\n"); + //printf("TypeInstance::deduceType(tparam = %s) %s\n", tparam->toChars(), toChars()); //printf("\ttparam = %d, ", tparam->ty); tparam->print(); // Extra check @@ -1356,14 +1367,14 @@ { TypeInstance *tp = (TypeInstance *)tparam; - for (int i = 0; i < idents.dim; i++) - { - Identifier *id1 = (Identifier *)idents.data[i]; - Identifier *id2 = (Identifier *)tp->idents.data[i]; - - if (!id1->equals(id2)) + //printf("tempinst->tempdecl = %p\n", tempinst->tempdecl); + //printf("tp->tempinst->tempdecl = %p\n", tp->tempinst->tempdecl); + if (!tp->tempinst->tempdecl) + { if (!tp->tempinst->name->equals(tempinst->name)) goto Lnomatch; } + else if (tempinst->tempdecl != tp->tempinst->tempdecl) + goto Lnomatch; for (int i = 0; i < tempinst->tiargs->dim; i++) { @@ -1439,11 +1450,35 @@ * to a template instance, too, and try again. */ TemplateInstance *ti = sym->parent->isTemplateInstance(); - if (ti && ti->toAlias() == sym && - tparam && tparam->ty == Tinstance) + + if (tparam && tparam->ty == Tinstance) { - TypeInstance *t = new TypeInstance(0, ti); - return t->deduceType(sc, tparam, parameters, dedtypes); + if (ti && ti->toAlias() == sym) + { + TypeInstance *t = new TypeInstance(0, ti); + return t->deduceType(sc, tparam, parameters, dedtypes); + } + + /* Match things like: + * S!(T).foo + */ + TypeInstance *tpi = (TypeInstance *)tparam; + if (tpi->idents.dim) + { Identifier *id = (Identifier *)tpi->idents.data[tpi->idents.dim - 1]; + if (id->dyncast() == DYNCAST_IDENTIFIER && sym->ident->equals(id)) + { + Type *tparent = sym->parent->getType(); + if (tparent) + { + /* Slice off the .foo in S!(T).foo + */ + tpi->idents.dim--; + MATCH m = tparent->deduceType(sc, tpi, parameters, dedtypes); + tpi->idents.dim++; + return m; + } + } + } } // Extra check @@ -1492,11 +1527,35 @@ * to a template instance, too, and try again. */ TemplateInstance *ti = sym->parent->isTemplateInstance(); - if (ti && ti->toAlias() == sym && - tparam && tparam->ty == Tinstance) + + if (tparam && tparam->ty == Tinstance) { - TypeInstance *t = new TypeInstance(0, ti); - return t->deduceType(sc, tparam, parameters, dedtypes); + if (ti && ti->toAlias() == sym) + { + TypeInstance *t = new TypeInstance(0, ti); + return t->deduceType(sc, tparam, parameters, dedtypes); + } + + /* Match things like: + * S!(T).foo + */ + TypeInstance *tpi = (TypeInstance *)tparam; + if (tpi->idents.dim) + { Identifier *id = (Identifier *)tpi->idents.data[tpi->idents.dim - 1]; + if (id->dyncast() == DYNCAST_IDENTIFIER && sym->ident->equals(id)) + { + Type *tparent = sym->parent->getType(); + if (tparent) + { + /* Slice off the .foo in S!(T).foo + */ + tpi->idents.dim--; + MATCH m = tparent->deduceType(sc, tpi, parameters, dedtypes); + tpi->idents.dim++; + return m; + } + } + } } // Extra check @@ -2271,7 +2330,7 @@ else { ovar = new Tuple(); - //printf("test3: ovar = %p\n", ovar); + //printf("ovar = %p\n", ovar); if (i < tiargs->dim) { //printf("i = %d, tiargs->dim = %d\n", i, tiargs->dim); @@ -2351,7 +2410,7 @@ printf("TemplateInstance(this = %p, ident = '%s')\n", this, ident ? ident->toChars() : "null"); #endif this->loc = loc; - this->idents.push(ident); + this->name = ident; this->tiargs = NULL; this->tempdecl = NULL; this->inst = NULL; @@ -2373,7 +2432,7 @@ printf("TemplateInstance(this = %p, tempdecl = '%s')\n", this, td->toChars()); #endif this->loc = loc; - this->idents.push(td->ident); + this->name = td->ident; this->tiargs = tiargs; this->tempdecl = td; this->inst = NULL; @@ -2398,11 +2457,7 @@ if (s) ti = (TemplateInstance *)s; else - ti = new TemplateInstance(loc, (Identifier *)idents.data[0]); - - ti->idents.setDim(idents.dim); - for (i = 1; i < idents.dim; i++) - ti->idents.data[i] = idents.data[i]; + ti = new TemplateInstance(loc, name); ti->tiargs = new Objects(); ti->tiargs->setDim(tiargs->dim); @@ -2424,11 +2479,6 @@ } -void TemplateInstance::addIdent(Identifier *ident) -{ - idents.push(ident); -} - void TemplateInstance::semantic(Scope *sc) { if (global.errors) @@ -2477,6 +2527,8 @@ semanticTiargs(sc); tempdecl = findTemplateDeclaration(sc); + if (tempdecl) + tempdecl = findBestMatch(sc); if (!tempdecl || global.errors) { inst = this; //printf("error return %p, %d\n", tempdecl, global.errors); @@ -2818,66 +2870,51 @@ if (!tempdecl) { /* Given: - * instance foo.bar.abc( ... ) - * figure out which TemplateDeclaration foo.bar.abc refers to. + * foo!( ... ) + * figure out which TemplateDeclaration foo refers to. */ Dsymbol *s; Dsymbol *scopesym; Identifier *id; int i; - id = (Identifier *)idents.data[0]; + id = name; s = sc->search(loc, id, &scopesym); - if (s) - { + if (!s) + { error("identifier '%s' is not defined", id->toChars()); + return NULL; + } #if LOG - printf("It's an instance of '%s' kind '%s'\n", s->toChars(), s->kind()); - printf("s->parent = '%s'\n", s->parent->toChars()); + printf("It's an instance of '%s' kind '%s'\n", s->toChars(), s->kind()); + printf("s->parent = '%s'\n", s->parent->toChars()); #endif - withsym = scopesym->isWithScopeSymbol(); + withsym = scopesym->isWithScopeSymbol(); - /* We might have found an alias within a template when - * we really want the template. - */ - TemplateInstance *ti; - if (idents.dim == 1 && s->parent && - (ti = s->parent->isTemplateInstance()) != NULL) - { - if ( - (ti->idents.data[ti->idents.dim - 1] == id || - ti->toAlias()->ident == id) - && - ti->tempdecl) - { - /* This is so that one can refer to the enclosing - * template, even if it has the same name as a member - * 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 - s = tempdecl; - } - } - - s = s->toAlias(); - for (i = 1; i < idents.dim; i++) - { Dsymbol *sm; - - id = (Identifier *)idents.data[i]; - sm = s->search(loc, id, 0); - if (!sm) - { - s = NULL; - break; - } - s = sm->toAlias(); + /* We might have found an alias within a template when + * we really want the template. + */ + TemplateInstance *ti; + if (s->parent && + (ti = s->parent->isTemplateInstance()) != NULL) + { + if ( + (ti->name == id || + ti->toAlias()->ident == id) + && + ti->tempdecl) + { + /* This is so that one can refer to the enclosing + * template, even if it has the same name as a member + * 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 + s = tempdecl; } } - if (!s) - { error("identifier '%s' is not defined", id->toChars()); - return NULL; - } + + s = s->toAlias(); /* It should be a TemplateDeclaration, not some other symbol */ @@ -2895,13 +2932,15 @@ } s = s2; } - assert(s->parent); - TemplateInstance *ti = s->parent->isTemplateInstance(); +#ifdef DEBUG + //if (!s->parent) printf("s = %s %s\n", s->kind(), s->toChars()); +#endif + //assert(s->parent); + TemplateInstance *ti = s->parent ? s->parent->isTemplateInstance() : NULL; if (ti && - (ti->idents.data[ti->idents.dim - 1] == id || + (ti->name == id || ti->toAlias()->ident == id) && - idents.dim == 1 && ti->tempdecl) { /* This is so that one can refer to the enclosing @@ -2921,7 +2960,11 @@ } else assert(tempdecl->isTemplateDeclaration()); + return tempdecl; +} +TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc) +{ /* Since there can be multiple TemplateDeclaration's with the same * name, look for the best match. */ @@ -3301,13 +3344,8 @@ { int i; - for (i = 0; i < idents.dim; i++) - { Identifier *id = (Identifier *)idents.data[i]; - - if (i) - buf->writeByte('.'); - buf->writestring(id->toChars()); - } + Identifier *id = name; + buf->writestring(id->toChars()); buf->writestring("!("); if (nest) buf->writestring("..."); @@ -3405,7 +3443,7 @@ /* ======================== TemplateMixin ================================ */ -TemplateMixin::TemplateMixin(Loc loc, Identifier *ident, TypeTypeof *tqual, +TemplateMixin::TemplateMixin(Loc loc, Identifier *ident, Type *tqual, Array *idents, Objects *tiargs) : TemplateInstance(loc, (Identifier *)idents->data[idents->dim - 1]) { @@ -3425,7 +3463,7 @@ for (int i = 0; i < idents->dim; i++) { // Matches TypeQualified::syntaxCopyHelper() Identifier *id = (Identifier *)idents->data[i]; - if (id->dyncast() != DYNCAST_IDENTIFIER) + if (id->dyncast() == DYNCAST_DSYMBOL) { TemplateInstance *ti = (TemplateInstance *)id; @@ -3436,7 +3474,7 @@ } tm = new TemplateMixin(loc, ident, - (TypeTypeof *)(tqual ? tqual->syntaxCopy() : NULL), + (Type *)(tqual ? tqual->syntaxCopy() : NULL), ids, tiargs); TemplateInstance::syntaxCopy(tm); return tm; @@ -3485,54 +3523,30 @@ { i = 1; id = (Identifier *)idents->data[0]; - if (id->dyncast() == DYNCAST_IDENTIFIER) + switch (id->dyncast()) { - s = sc->search(loc, id, NULL); - } - else - { - TemplateInstance *ti = (TemplateInstance *)id; - ti->semantic(sc); - s = ti; + case DYNCAST_IDENTIFIER: + s = sc->search(loc, id, NULL); + break; + + case DYNCAST_DSYMBOL: + { + TemplateInstance *ti = (TemplateInstance *)id; + ti->semantic(sc); + s = ti; + break; + } + default: + assert(0); } } for (; i < idents->dim; i++) - { Dsymbol *sm; - + { if (!s) break; - s = s->toAlias(); id = (Identifier *)idents->data[i]; - if (id->dyncast() == DYNCAST_IDENTIFIER) - { - sm = s->search(loc, id, 0); - } - else - { - // It's a template instance - //printf("\ttemplate instance id\n"); - TemplateDeclaration *td; - TemplateInstance *ti = (TemplateInstance *)id; - id = (Identifier *)ti->idents.data[0]; - sm = s->search(loc, id, 0); - if (!sm) - { error("template identifier %s is not a member of %s", id->toChars(), s->toChars()); - return; - } - sm = sm->toAlias(); - td = sm->isTemplateDeclaration(); - if (!td) - { - error("%s is not a template", id->toChars()); - inst = this; - return; - } - ti->tempdecl = td; - ti->semantic(sc); - sm = ti->toAlias(); - } - s = sm; + s = s->searchX(loc, sc, id); } if (!s) { @@ -3543,7 +3557,7 @@ tempdecl = s->toAlias()->isTemplateDeclaration(); if (!tempdecl) { - error("%s is not a template", s->toChars()); + error("%s isn't a template", s->toChars()); inst = this; return; } @@ -3580,7 +3594,7 @@ // Run semantic on each argument, place results in tiargs[] semanticTiargs(sc); - tempdecl = findTemplateDeclaration(sc); + tempdecl = findBestMatch(sc); if (!tempdecl) { inst = this; return; // error recovery diff -uNr dmd-1.010/dmd/src/dmd/template.h dmd-1.011/dmd/src/dmd/template.h --- dmd-1.010/dmd/src/dmd/template.h 2007-03-12 01:10:36.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/template.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -226,10 +226,12 @@ struct TemplateInstance : ScopeDsymbol { /* Given: - * template abc(T:T*, S, int V) - * instance foo.bar.abc(int*, char, 10*10) + * foo!(args) => + * name = foo + * tiargs = args */ - Array idents; // Array of Identifiers [foo, bar, abc] + Identifier *name; + //Array idents; Objects *tiargs; // Array of Types/Expressions of template // instance arguments [int*, char, 10*10] @@ -258,7 +260,6 @@ TemplateInstance(Loc loc, Identifier *temp_id); TemplateInstance(Loc loc, TemplateDeclaration *tempdecl, Objects *tiargs); Dsymbol *syntaxCopy(Dsymbol *); - void addIdent(Identifier *ident); void semantic(Scope *sc); void semantic2(Scope *sc); void semantic3(Scope *sc); @@ -275,6 +276,7 @@ // Internal void semanticTiargs(Scope *sc); TemplateDeclaration *findTemplateDeclaration(Scope *sc); + TemplateDeclaration *findBestMatch(Scope *sc); void declareParameters(Scope *sc); int isNested(Objects *tiargs); Identifier *genIdent(); @@ -286,11 +288,11 @@ struct TemplateMixin : TemplateInstance { Array *idents; - TypeTypeof *tqual; + Type *tqual; Scope *scope; // for forward referencing - TemplateMixin(Loc loc, Identifier *ident, TypeTypeof *tqual, Array *idents, Objects *tiargs); + TemplateMixin(Loc loc, Identifier *ident, Type *tqual, Array *idents, Objects *tiargs); Dsymbol *syntaxCopy(Dsymbol *s); void semantic(Scope *sc); void semantic2(Scope *sc); diff -uNr dmd-1.010/dmd/src/dmd/tocsym.c dmd-1.011/dmd/src/dmd/tocsym.c --- dmd-1.010/dmd/src/dmd/tocsym.c 2007-03-07 18:10:52.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/tocsym.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -173,7 +173,7 @@ id = ident->toChars(); s = symbol_calloc(id); - if (storage_class & STCout) + if (storage_class & (STCout | STCref)) { if (global.params.symdebug && storage_class & STCparameter) { diff -uNr dmd-1.010/dmd/src/dmd/todt.c dmd-1.011/dmd/src/dmd/todt.c --- dmd-1.010/dmd/src/dmd/todt.c 2007-03-24 21:17:40.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/todt.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/toir.c dmd-1.011/dmd/src/dmd/toir.c --- dmd-1.010/dmd/src/dmd/toir.c 2007-01-01 21:29:14.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/toir.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/toir.h dmd-1.011/dmd/src/dmd/toir.h --- dmd-1.010/dmd/src/dmd/toir.h 2006-11-20 19:19:36.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/toir.h 2007-04-10 14:38:58.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/toobj.c dmd-1.011/dmd/src/dmd/toobj.c --- dmd-1.010/dmd/src/dmd/toobj.c 2007-03-15 21:22:26.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/toobj.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/total.h dmd-1.011/dmd/src/dmd/total.h --- dmd-1.010/dmd/src/dmd/total.h 2006-10-05 17:04:10.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/total.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/typinf.c dmd-1.011/dmd/src/dmd/typinf.c --- dmd-1.010/dmd/src/dmd/typinf.c 2007-02-09 01:13:28.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/typinf.c 2007-04-10 14:39:00.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. @@ -428,7 +428,7 @@ { Scope sc; Arguments *arguments = new Arguments; - Argument *arg = new Argument(In, tc->pointerTo(), NULL, NULL); + Argument *arg = new Argument(STCin, tc->pointerTo(), NULL, NULL); arguments->push(arg); tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd); @@ -646,7 +646,7 @@ Arguments *args = new Arguments; args->setDim(dim); for (size_t i = 0; i < dim; i++) - { Argument *arg = new Argument(In, exps[i]->type, NULL, NULL); + { Argument *arg = new Argument(STCin, exps[i]->type, NULL, NULL); args->data[i] = (void *)arg; } TypeTuple *tup = new TypeTuple(args); diff -uNr dmd-1.010/dmd/src/dmd/unialpha.c dmd-1.011/dmd/src/dmd/unialpha.c --- dmd-1.010/dmd/src/dmd/unialpha.c 2005-03-05 02:25:42.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/unialpha.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 2003 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/utf.c dmd-1.011/dmd/src/dmd/utf.c --- dmd-1.010/dmd/src/dmd/utf.c 2006-11-13 16:38:56.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/utf.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 2003 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/utf.h dmd-1.011/dmd/src/dmd/utf.h --- dmd-1.010/dmd/src/dmd/utf.h 2006-11-13 16:39:36.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/utf.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 2003-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/version.c dmd-1.011/dmd/src/dmd/version.c --- dmd-1.010/dmd/src/dmd/version.c 2006-02-27 23:28:04.000000000 +0100 +++ dmd-1.011/dmd/src/dmd/version.c 2007-04-10 14:39:00.000000000 +0200 @@ -2,7 +2,7 @@ // Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/dmd/version.h dmd-1.011/dmd/src/dmd/version.h --- dmd-1.010/dmd/src/dmd/version.h 2006-10-05 17:04:02.000000000 +0200 +++ dmd-1.011/dmd/src/dmd/version.h 2007-04-10 14:38:58.000000000 +0200 @@ -3,7 +3,7 @@ // Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright -// www.digitalmars.com +// http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. diff -uNr dmd-1.010/dmd/src/phobos/internal/gc/gc.d dmd-1.011/dmd/src/phobos/internal/gc/gc.d --- dmd-1.010/dmd/src/phobos/internal/gc/gc.d 2007-03-26 00:46:30.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/internal/gc/gc.d 2007-04-11 00:38:08.000000000 +0200 @@ -833,7 +833,7 @@ byte *argp = cast(byte *)(&ti + 2); *cast(size_t *)&x = newlength; - (cast(byte *)x)[length * sizeelem .. newsize] = argp[0 .. sizeelem]; + x.ptr[length * sizeelem .. newsize] = argp[0 .. sizeelem]; assert((cast(size_t)x.ptr & 15) == 0); assert(_gc.capacity(x.ptr) > x.length * sizeelem); return x; diff -uNr dmd-1.010/dmd/src/phobos/internal/gc/gcx.d dmd-1.011/dmd/src/phobos/internal/gc/gcx.d --- dmd-1.010/dmd/src/phobos/internal/gc/gcx.d 2007-03-26 00:46:30.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/internal/gc/gcx.d 2007-04-11 00:38:08.000000000 +0200 @@ -104,17 +104,19 @@ if (!data) { data = cast(Log *)std.c.stdlib.malloc(allocdim * Log.sizeof); + if (!data && allocdim) + _d_OutOfMemory(); } else { Log *newdata; newdata = cast(Log *)std.c.stdlib.malloc(allocdim * Log.sizeof); - assert(newdata); + if (!newdata && allocdim) + _d_OutOfMemory(); memcpy(newdata, data, dim * Log.sizeof); std.c.stdlib.free(data); data = newdata; } - assert(!allocdim || data); } } @@ -178,6 +180,8 @@ { gcLock = GCLock.classinfo; gcx = cast(Gcx *)std.c.stdlib.calloc(1, Gcx.sizeof); + if (!gcx) + _d_OutOfMemory(); gcx.initialize(); version (Win32) { @@ -1047,7 +1051,8 @@ void **newroots; newroots = cast(void **)std.c.stdlib.malloc(newdim * newroots[0].sizeof); - assert(newroots); + if (!newroots) + _d_OutOfMemory(); if (roots) { memcpy(newroots, roots, nroots * newroots[0].sizeof); std.c.stdlib.free(roots); @@ -1088,7 +1093,8 @@ Range *newranges; newranges = cast(Range *)std.c.stdlib.malloc(newdim * newranges[0].sizeof); - assert(newranges); + if (!newranges) + _d_OutOfMemory(); if (ranges) { memcpy(newranges, ranges, nranges * newranges[0].sizeof); std.c.stdlib.free(ranges); @@ -1341,6 +1347,12 @@ // Minimum of POOLSIZE if (npages < POOLSIZE/PAGESIZE) npages = POOLSIZE/PAGESIZE; + else if (npages > POOLSIZE/PAGESIZE) + { // Give us 150% of requested size, so there's room to extend + auto n = npages + (npages >> 1); + if (n < size_t.max/PAGESIZE) + npages = n; + } // Allocate successively larger pools up to 8 megs if (npools) @@ -2080,6 +2092,8 @@ noptrs.alloc(poolsize / 16); pagetable = cast(ubyte*)std.c.stdlib.malloc(npages); + if (!pagetable) + _d_OutOfMemory(); memset(pagetable, B_UNCOMMITTED, npages); this.npages = npages; diff -uNr dmd-1.010/dmd/src/phobos/internal/object.d dmd-1.011/dmd/src/phobos/internal/object.d --- dmd-1.010/dmd/src/phobos/internal/object.d 2007-03-26 00:46:28.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/internal/object.d 2007-04-11 00:38:08.000000000 +0200 @@ -262,12 +262,12 @@ int offset; /// offset to Interface 'this' from Object 'this' } +import std.moduleinit; /** * Runtime type information about a class. Can be retrieved for any class type * or instance by using the .classinfo property. * A pointer to this appears as the first entry in the class's vtbl[]. */ -import std.moduleinit; class ClassInfo : Object { byte[] init; /** class static initializer diff -uNr dmd-1.010/dmd/src/phobos/std/c/locale.d dmd-1.011/dmd/src/phobos/std/c/locale.d --- dmd-1.010/dmd/src/phobos/std/c/locale.d 2007-03-26 00:46:28.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/std/c/locale.d 2007-04-11 00:38:08.000000000 +0200 @@ -1,10 +1,10 @@ -/** +/** * C's <locale.h> * License: Public Domain * Standards: - * ISO/IEC 9899:1999 §7.11 + * ISO/IEC 9899:1999 7.11 * Macros: - * WIKI=Phobos/StdCCType + * WIKI=Phobos/StdCLocale */ module std.c.locale; @@ -26,8 +26,8 @@ char* grouping; /** The international currency symbol applicable to the current locale. - * The first three characters contain the alphabetic international - * currency symbol in accordance with those specified in ISO 4217. + * The first three characters contain the alphabetic international + * currency symbol in accordance with those specified in ISO 4217. * The fourth character (immediately preceding the null character) * is the character used to separate the international currency symbol * from the monetary quantity. @@ -135,11 +135,11 @@ **/ const LC_MONETARY = 4; -/// The program’s entire locale. +/// The program's entire locale. const LC_ALL = 6; /** The setlocale function selects the appropriate portion of the program's - * locale as specified by the category and locale arguments. + * locale as specified by the category and locale arguments. **/ char* setlocale(int category, char* locale); diff -uNr dmd-1.010/dmd/src/phobos/std/stdio.d dmd-1.011/dmd/src/phobos/std/stdio.d --- dmd-1.010/dmd/src/phobos/std/stdio.d 2007-03-26 00:46:28.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/std/stdio.d 2007-04-11 00:38:08.000000000 +0200 @@ -328,7 +328,7 @@ { if (c >= 0xD800 && c <= 0xDBFF) { - if ((c2 == FGETWC(fp)) != -1 || + if ((c2 = FGETWC(fp)) != -1 || c2 < 0xDC00 && c2 > 0xDFFF) { StdioException("unpaired UTF-16 surrogate"); @@ -475,7 +475,7 @@ { if (c >= 0xD800 && c <= 0xDBFF) { - if ((c2 == FGETWC(fp)) != -1 || + if ((c2 = FGETWC(fp)) != -1 || c2 < 0xDC00 && c2 > 0xDFFF) { StdioException("unpaired UTF-16 surrogate"); diff -uNr dmd-1.010/dmd/src/phobos/std/windows/registry.d dmd-1.011/dmd/src/phobos/std/windows/registry.d --- dmd-1.010/dmd/src/phobos/std/windows/registry.d 2007-03-26 00:46:28.000000000 +0200 +++ dmd-1.011/dmd/src/phobos/std/windows/registry.d 2007-04-11 00:38:08.000000000 +0200 @@ -1618,7 +1618,7 @@ } private: - this(); + this() { } /// \name Hives //@{