changeset 1234:9201e0d41ee5

Fixed forward referenced structs.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 16 Apr 2009 20:41:27 +0200
parents 1e699a4e9759
children ded6a557220a
files gen/structs.cpp ir/irtypestruct.cpp
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gen/structs.cpp	Thu Apr 16 20:31:21 2009 +0200
+++ b/gen/structs.cpp	Thu Apr 16 20:41:27 2009 +0200
@@ -36,6 +36,10 @@
     // 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;
--- a/ir/irtypestruct.cpp	Thu Apr 16 20:31:21 2009 +0200
+++ b/ir/irtypestruct.cpp	Thu Apr 16 20:41:27 2009 +0200
@@ -67,6 +67,10 @@
     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.