Mercurial > projects > ddmd
diff dmd/ClassDeclaration.d @ 89:37b95c347975
Fixed an obscure bug with i variable being reused
author | korDen |
---|---|
date | Mon, 30 Aug 2010 23:25:50 +0400 |
parents | 23280d154c5b |
children | 0c891ec48515 |
line wrap: on
line diff
--- a/dmd/ClassDeclaration.d Mon Aug 30 19:58:14 2010 +0400 +++ b/dmd/ClassDeclaration.d Mon Aug 30 23:25:50 2010 +0400 @@ -307,7 +307,6 @@ override void semantic(Scope sc) { - int i; uint offset; //printf("ClassDeclaration.semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this); @@ -364,7 +363,7 @@ error("cannot create C++ classes"); // Expand any tuples in baseclasses[] - for (i = 0; i < baseclasses.dim; ) + for (int i = 0; i < baseclasses.dim; ) { BaseClass b = cast(BaseClass)baseclasses.data[i]; //printf("test1 %s %s\n", toChars(), b.type.toChars()); @@ -459,7 +458,7 @@ // Treat the remaining entries in baseclasses as interfaces // Check for errors, handle forward references - for (i = (baseClass ? 1 : 0); i < baseclasses.dim; ) + for (int i = (baseClass ? 1 : 0); i < baseclasses.dim; ) { TypeClass tc; BaseClass b; Type tb; @@ -690,10 +689,10 @@ } structsize = sc.offset; Scope scsave = sc; /// a copy must be created? - int members_dim = members.dim; sizeok = 0; - foreach (s; members) + foreach (Dsymbol s; members) { s.semantic(sc); + } if (sizeok == 2) { // semantic() failed because of forward references. @@ -764,7 +763,7 @@ } // Allocate instance of each new interface - for (i = 0; i < vtblInterfaces.dim; i++) + for (int i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; uint thissize = PTRSIZE; @@ -794,7 +793,7 @@ static if (false) { // Do not call until toObjfile() because of forward references // Fill in base class vtbl[]s - for (i = 0; i < vtblInterfaces.dim; i++) + for (int i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; @@ -1177,7 +1176,6 @@ // Back end override void toObjFile(int multiobj) // compile to .obj file { - uint i; uint offset; Symbol* sinit; enum_SC scclass; @@ -1239,7 +1237,7 @@ // Call each of the destructors in dtors[] // in reverse order - for (i = 0; i < dtors.dim; i++) + for (size_t i = 0; i < dtors.dim; i++) { DtorDeclaration d = cast(DtorDeclaration)dtors.data[i]; Symbol* s = d.toSymbol(); @@ -1437,7 +1435,7 @@ // of the fixup (*) offset += vtblInterfaces.dim * (4 * PTRSIZE); - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; ClassDeclaration id = b.base; @@ -1467,7 +1465,7 @@ // Put out the vtblInterfaces.data[].vtbl[] // This must be mirrored with ClassDeclaration.baseVtblOffset() //printf("putting out %d interface vtbl[]s for '%s'\n", vtblInterfaces.dim, toChars()); - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; ClassDeclaration id = b.base; @@ -1557,7 +1555,7 @@ // Put out the overriding interface vtbl[]s. // This must be mirrored with ClassDeclaration.baseVtblOffset() //printf("putting out overriding interface vtbl[]s for '%s' at offset x%x\n", toChars(), offset); - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; ClassDeclaration cd; @@ -1615,6 +1613,7 @@ // Put out the vtbl[] //printf("putting out %s.vtbl[]\n", toChars()); dt = null; + size_t i; if (0) i = 0; else @@ -1693,13 +1692,12 @@ uint baseVtblOffset(BaseClass bc) { uint csymoffset; - int i; //printf("ClassDeclaration.baseVtblOffset('%s', bc = %p)\n", toChars(), bc); csymoffset = CLASSINFO_SIZE; csymoffset += vtblInterfaces.dim * (4 * PTRSIZE); - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; @@ -1734,7 +1732,7 @@ } } version (INTERFACE_VIRTUAL) { - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i]; ClassDeclaration cd; @@ -1828,7 +1826,7 @@ void toDt2(dt_t** pdt, ClassDeclaration cd) { uint offset; - uint i; + dt_t* dt; uint csymoffset; @@ -1846,7 +1844,7 @@ } // Note equivalence of this loop to struct's - for (i = 0; i < fields.dim; i++) + for (size_t i = 0; i < fields.dim; i++) { VarDeclaration v = cast(VarDeclaration)fields[i]; Initializer init; @@ -1885,7 +1883,7 @@ // Interface vptr initializations toSymbol(); // define csym - for (i = 0; i < vtblInterfaces.dim; i++) + for (size_t i = 0; i < vtblInterfaces.dim; i++) { BaseClass b = cast(BaseClass)vtblInterfaces.data[i];