Mercurial > projects > ldc
diff dmd/mtype.c @ 92:70d6113eeb8c trunk
[svn r96] Updated to DMD 1.023.
Regular bugfixes.
author | lindquist |
---|---|
date | Thu, 08 Nov 2007 19:13:28 +0100 |
parents | 3cfcb944304e |
children | 61615fa85940 |
line wrap: on
line diff
--- a/dmd/mtype.c Wed Nov 07 04:52:56 2007 +0100 +++ b/dmd/mtype.c Thu Nov 08 19:13:28 2007 +0100 @@ -489,7 +489,7 @@ } -Expression *Type::defaultInit() +Expression *Type::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("Type::defaultInit() '%s'\n", toChars()); @@ -556,8 +556,7 @@ { if (ty == Tvoid) error(loc, "void does not have an initializer"); - e = defaultInit(); - e->loc = loc; + e = defaultInit(loc); } else if (ident == Id::mangleof) { @@ -634,7 +633,7 @@ e->isBool(0) && v->type->toBasetype()->ty == Tstruct) { - e = v->type->defaultInit(); + e = v->type->defaultInit(loc); } } e = e->optimize(WANTvalue | WANTinterpret); @@ -644,8 +643,7 @@ return e; } #endif - Expression *ex = defaultInit(); - ex->loc = e->loc; + Expression *ex = defaultInit(e->loc); return ex; } } @@ -1327,7 +1325,7 @@ return e; } -Expression *TypeBasic::defaultInit() +Expression *TypeBasic::defaultInit(Loc loc) { integer_t value = 0; #if LOGDEFAULTINIT @@ -1353,9 +1351,9 @@ case Tcomplex32: case Tcomplex64: case Tcomplex80: - return getProperty(0, Id::nan); - } - return new IntegerExp(0, value, this); + return getProperty(loc, Id::nan); + } + return new IntegerExp(loc, value, this); } int TypeBasic::isZeroInit() @@ -1825,6 +1823,14 @@ dim = semanticLength(sc, tbn, dim); dim = dim->optimize(WANTvalue | WANTinterpret); + if (sc->parameterSpecialization && dim->op == TOKvar && + ((VarExp *)dim)->var->storage_class & STCtemplateparameter) + { + /* It could be a template parameter N which has no value yet: + * template Foo(T : T[N], size_t N); + */ + return this; + } integer_t d1 = dim->toInteger(); dim = dim->castTo(sc, tsize_t); dim = dim->optimize(WANTvalue); @@ -1969,12 +1975,12 @@ return Type::implicitConvTo(to); } -Expression *TypeSArray::defaultInit() +Expression *TypeSArray::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeSArray::defaultInit() '%s'\n", toChars()); #endif - return next->defaultInit(); + return next->defaultInit(loc); } int TypeSArray::isZeroInit() @@ -2127,13 +2133,13 @@ return Type::implicitConvTo(to); } -Expression *TypeDArray::defaultInit() +Expression *TypeDArray::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeDArray::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; } @@ -2341,13 +2347,13 @@ buf->writeByte(']'); } -Expression *TypeAArray::defaultInit() +Expression *TypeAArray::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeAArray::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; } @@ -2449,13 +2455,13 @@ return TRUE; } -Expression *TypePointer::defaultInit() +Expression *TypePointer::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypePointer::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; } @@ -2516,13 +2522,13 @@ return next->dotExp(sc, e, ident); } -Expression *TypeReference::defaultInit() +Expression *TypeReference::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeReference::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; } @@ -3000,13 +3006,13 @@ #endif } -Expression *TypeDelegate::defaultInit() +Expression *TypeDelegate::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeDelegate::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; } @@ -3800,7 +3806,7 @@ { if (!sym->symtab) goto Lfwd; - e = defaultInit(); + e = defaultInit(loc); } else { @@ -3849,14 +3855,14 @@ return m; } -Expression *TypeEnum::defaultInit() +Expression *TypeEnum::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeEnum::defaultInit() '%s'\n", toChars()); #endif // Initialize to first member of enum Expression *e; - e = new IntegerExp(0, sym->defaultval, this); + e = new IntegerExp(loc, sym->defaultval, this); return e; } @@ -4024,7 +4030,7 @@ return m; } -Expression *TypeTypedef::defaultInit() +Expression *TypeTypedef::defaultInit(Loc loc) { Expression *e; Type *bt; @@ -4037,7 +4043,7 @@ return sym->init->toExpression(); } bt = sym->basetype; - e = bt->defaultInit(); + e = bt->defaultInit(loc); e->type = this; while (bt->ty == Tsarray) { @@ -4316,7 +4322,7 @@ return sym->structalign; } -Expression *TypeStruct::defaultInit() +Expression *TypeStruct::defaultInit(Loc loc) { Symbol *s; Declaration *d; @@ -4701,13 +4707,13 @@ return MATCHnomatch; } -Expression *TypeClass::defaultInit() +Expression *TypeClass::defaultInit(Loc loc) { #if LOGDEFAULTINIT printf("TypeClass::defaultInit() '%s'\n", toChars()); #endif Expression *e; - e = new NullExp(0); + e = new NullExp(loc); e->type = this; return e; }