changeset 1345:712662f45ee4

Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Mon, 11 May 2009 20:54:25 +0200
parents 3297edb697eb
children 6f4154b318ef
files gen/typinf.cpp
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gen/typinf.cpp	Mon May 11 15:48:33 2009 +0200
+++ b/gen/typinf.cpp	Mon May 11 20:54:25 2009 +0200
@@ -652,6 +652,14 @@
     assert(tinfo->ty == Tstruct);
     TypeStruct *tc = (TypeStruct *)tinfo;
     StructDeclaration *sd = tc->sym;
+
+    // can't emit typeinfo for forward declarations
+    if (sd->sizeok != 1)
+    {
+        sd->error("cannot emit TypeInfo for forward declaration");
+        fatal();
+    }
+
     sd->codegen(Type::sir);
 
     ClassDeclaration* base = Type::typeinfostruct;