Mercurial > projects > ldc
diff ir/irstruct.cpp @ 1270:dd135ff697fa
Fixed class default initializers and type generation. Bug #260 is fixed.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Mon, 27 Apr 2009 03:40:40 +0200 |
parents | ec1d9dc1d32a |
children | 8d501abecd24 |
line wrap: on
line diff
--- a/ir/irstruct.cpp Mon Apr 27 01:43:29 2009 +0200 +++ b/ir/irstruct.cpp Mon Apr 27 03:40:40 2009 +0200 @@ -19,7 +19,8 @@ ////////////////////////////////////////////////////////////////////////////// IrStruct::IrStruct(AggregateDeclaration* aggr) -: diCompositeType(NULL) +: diCompositeType(NULL), + init_pa(llvm::OpaqueType::get()) { aggrdecl = aggr; @@ -57,7 +58,7 @@ llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); init = new llvm::GlobalVariable( - type->irtype->getPA().get(), true, _linkage, NULL, initname, gIR->module); + init_pa.get(), true, _linkage, NULL, initname, gIR->module); return init; } @@ -78,6 +79,9 @@ constInit = createClassDefaultInitializer(); } + llvm::OpaqueType* o = llvm::cast<llvm::OpaqueType>(init_pa.get()); + o->refineAbstractTypeTo(constInit->getType()); + return constInit; } @@ -157,11 +161,7 @@ { VarDeclaration* vd = *it; - if (vd->offset < offset) - { - IF_LOG Logger::println("skipping field: %s %s (+%u)", vd->type->toChars(), vd->toChars(), vd->offset); - continue; - } + assert(vd->offset >= offset && "default fields not sorted by offset"); IF_LOG Logger::println("using field: %s %s (+%u)", vd->type->toChars(), vd->toChars(), vd->offset);