Mercurial > projects > ldc
changeset 656:a15ccbf7451d
Support structs that are merely a forward reference. See mini/forwdecl1.d
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 06 Oct 2008 14:06:55 +0200 |
parents | 93433f4b6963 |
children | c42173b3557b |
files | gen/structs.cpp gen/toir.cpp tests/mini/forwdecl1.d |
diffstat | 3 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/structs.cpp Mon Oct 06 12:46:57 2008 +0200 +++ b/gen/structs.cpp Mon Oct 06 14:06:55 2008 +0200 @@ -131,10 +131,16 @@ Logger::println("DtoResolveStruct(%s): %s", sd->toChars(), sd->loc.toChars()); LOG_SCOPE; - if (sd->prot() == PROTprivate && sd->getModule() != gIR->dmodule) - Logger::println("using a private struct from outside its module"); + TypeStruct* ts = (TypeStruct*)sd->type->toBasetype(); - TypeStruct* ts = (TypeStruct*)sd->type->toBasetype(); + // this struct is a forward declaration + // didn't even know had those ... + if (sd->sizeok != 1) + { + sd->ir.irStruct = new IrStruct(ts); + ts->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get()); + return; + } bool ispacked = (ts->alignsize() == 1);
--- a/gen/toir.cpp Mon Oct 06 12:46:57 2008 +0200 +++ b/gen/toir.cpp Mon Oct 06 14:06:55 2008 +0200 @@ -129,10 +129,10 @@ if (vd->isDataseg() || (vd->storage_class & STCextern)) { vd->toObjFile(0); // TODO: multiobj } - if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) { - error("global variable %s not resolved", vd->toChars()); + if (!vd->ir.isSet() || !vd->ir.getIrValue()) { + error("variable %s not resolved", vd->toChars()); if (Logger::enabled()) - Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n'; + Logger::cout() << "unresolved variable had type: " << *DtoType(vd->type) << '\n'; fatal(); } if (vd->isDataseg() || (vd->storage_class & STCextern)) {