Mercurial > projects > ddmd
diff dmd/StructDeclaration.d @ 129:010eb8f0e18d
further work on dmd test suite
author | korDen |
---|---|
date | Sun, 05 Sep 2010 15:32:22 +0400 |
parents | 1765f3ef917d |
children | 60bb0fe4563e |
line wrap: on
line diff
--- a/dmd/StructDeclaration.d Sat Sep 04 01:33:05 2010 +0100 +++ b/dmd/StructDeclaration.d Sun Sep 05 15:32:22 2010 +0400 @@ -61,6 +61,8 @@ import dmd.backend.FL; import dmd.backend.glue; +import std.stdio; + class StructDeclaration : AggregateDeclaration { bool zeroInit; // true if initialize with 0 fill @@ -203,23 +205,33 @@ int members_dim = members.dim; foreach(Dsymbol s; members) { - s.semantic(sc2); - if (isUnionDeclaration()) - sc2.offset = 0; + s.semantic(sc2); + if (isUnionDeclaration()) + sc2.offset = 0; static if (false) { - if (sizeok == 2) - { //printf("forward reference\n"); - break; - } + if (sizeok == 2) + { //printf("forward reference\n"); + break; + } } - Type t; - if (s.isDeclaration() && - (t = s.isDeclaration().type) !is null && - t.toBasetype().ty == TY.Tstruct) - { StructDeclaration sd = cast(StructDeclaration)t.toDsymbol(sc); - if (sd.isnested) - error("inner struct %s cannot be a field", sd.toChars()); - } + if (auto d = s.isDeclaration()) + { + if (auto t = d.type) { + if (t.toBasetype().ty == TY.Tstruct) { + auto ad = t.toDsymbol(sc).isThis(); + /* + StructDeclaration sd = cast(StructDeclaration)foo; + if (foo && !sd) { + writeln(t.classin); + writeln(foo.classinfo.name); + assert(false); + } + */ + if (ad && ad.isnested) + error("inner struct %s cannot be a field", ad.toChars()); + } + } + } } /* The TypeInfo_Struct is expecting an opEquals and opCmp with @@ -231,22 +243,22 @@ TypeFunction tfeqptr; { - auto arguments = new Arguments; - auto arg = new Argument(STC.STCin, handle, Id.p, null); + Arguments arguments = new Arguments; + Argument arg = new Argument(STC.STCin, handle, Id.p, null); - arguments.push(arg); - tfeqptr = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd); - tfeqptr = cast(TypeFunction)tfeqptr.semantic(Loc(0), sc); + arguments.push(arg); + tfeqptr = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd); + tfeqptr = cast(TypeFunction)tfeqptr.semantic(Loc(0), sc); } TypeFunction tfeq; { - auto arguments = new Arguments; - auto arg = new Argument(STC.STCin, type, null, null); + Arguments arguments = new Arguments; + Argument arg = new Argument(STC.STCin, type, null, null); - arguments.push(arg); - tfeq = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd); - tfeq = cast(TypeFunction)tfeq.semantic(Loc(0), sc); + arguments.push(arg); + tfeq = new TypeFunction(arguments, Type.tint32, 0, LINK.LINKd); + tfeq = cast(TypeFunction)tfeq.semantic(Loc(0), sc); } Identifier id = Id.eq; @@ -437,8 +449,8 @@ FuncDeclaration fop = null; - auto param = new Argument(STC.STCnodtor, type, Id.p, null); - auto fparams = new Arguments; + Argument param = new Argument(STC.STCnodtor, type, Id.p, null); + Arguments fparams = new Arguments; fparams.push(param); Type ftype = new TypeFunction(fparams, handle, false, LINK.LINKd); version (STRUCTTHISREF) { @@ -650,41 +662,41 @@ */ if (postblit) { - //printf("generating cpctor\n"); + //printf("generating cpctor\n"); - auto param = new Argument(STC.STCref, type, Id.p, null); - auto fparams = new Arguments; - fparams.push(param); - Type ftype = new TypeFunction(fparams, Type.tvoid, false, LINK.LINKd); + Argument param = new Argument(STC.STCref, type, Id.p, null); + Arguments fparams = new Arguments; + fparams.push(param); + Type ftype = new TypeFunction(fparams, Type.tvoid, false, LINK.LINKd); - fcp = new FuncDeclaration(Loc(0), Loc(0), Id.cpctor, STC.STCundefined, ftype); + fcp = new FuncDeclaration(Loc(0), Loc(0), Id.cpctor, STC.STCundefined, ftype); - // Build *this = p; - Expression e = new ThisExp(Loc(0)); + // Build *this = p; + Expression e = new ThisExp(Loc(0)); version (STRUCTTHISREF) { } else { - e = new PtrExp(Loc(0), e); + e = new PtrExp(Loc(0), e); } - auto ea = new AssignExp(Loc(0), e, new IdentifierExp(Loc(0), Id.p)); - ea.op = TOK.TOKblit; - Statement s = new ExpStatement(Loc(0), ea); + AssignExp ea = new AssignExp(Loc(0), e, new IdentifierExp(Loc(0), Id.p)); + ea.op = TOK.TOKblit; + Statement s = new ExpStatement(Loc(0), ea); - // Build postBlit(); - e = new VarExp(Loc(0), postblit, 0); - e = new CallExp(Loc(0), e); + // Build postBlit(); + e = new VarExp(Loc(0), postblit, 0); + e = new CallExp(Loc(0), e); - s = new CompoundStatement(Loc(0), s, new ExpStatement(Loc(0), e)); - fcp.fbody = s; + s = new CompoundStatement(Loc(0), s, new ExpStatement(Loc(0), e)); + fcp.fbody = s; - members.push(fcp); + members.push(fcp); - sc = sc.push(); - sc.stc = STC.STCundefined; - sc.linkage = LINK.LINKd; + sc = sc.push(); + sc.stc = STC.STCundefined; + sc.linkage = LINK.LINKd; - fcp.semantic(sc); + fcp.semantic(sc); - sc.pop(); + sc.pop(); } return fcp;