From 414e58a3185efdeb9b942500c5aa2ac9cbc9ddce Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Thu, 16 Apr 2009 20:41:27 +0200 Subject: [PATCH] Fixed forward referenced structs. --- gen/structs.cpp | 4 ++++ ir/irtypestruct.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/gen/structs.cpp b/gen/structs.cpp index 1f5ee1c5..3cc96564 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -36,6 +36,10 @@ void DtoResolveStruct(StructDeclaration* sd) // make sure type exists DtoType(sd->type); + // if it's a forward declaration, all bets are off. The type should be enough + if (sd->sizeok != 1) + return; + // create the IrStruct IrStruct* irstruct = new IrStruct(sd); sd->ir.irStruct = irstruct; diff --git a/ir/irtypestruct.cpp b/ir/irtypestruct.cpp index 0105fde6..e50507cf 100644 --- a/ir/irtypestruct.cpp +++ b/ir/irtypestruct.cpp @@ -67,6 +67,10 @@ const llvm::Type* IrTypeStruct::buildType() IF_LOG Logger::println("Building struct type %s @ %s", sd->toPrettyChars(), sd->locToChars()); LOG_SCOPE; + // if it's a forward declaration, all bets are off, stick with the opaque + if (sd->sizeok != 1) + return pa.get(); + // find the fields that contribute to the default initializer. // these will define the default type.