[Commit] nickle compile.c,1.158,1.159

Bart Massey commit at keithp.com
Fri Oct 1 12:58:56 PDT 2004


Committed by: bart

Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv23538

Modified Files:
	compile.c 
Log Message:
Compiler dumped core when trying to create a variable of
incomplete structure type.



Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- compile.c	7 Jul 2004 07:32:47 -0000	1.158
+++ compile.c	1 Oct 2004 19:58:54 -0000	1.159
@@ -419,9 +419,13 @@
 }
 
 static TypePtr
-CompileRefType (TypePtr t)
+CompileRefType (ObjPtr obj, ExprPtr expr, TypePtr t)
 {
     t = TypeCanon (t);
+    if (!t) {
+	CompileError(obj, expr, "reference to incomplete type");
+	return 0;
+    }
 
     if (t->base.tag == type_ref && !t->ref.pointer)
 	return t->ref.ref;
@@ -622,7 +626,7 @@
     }
     if (flipTypes)
     {
-	t = CompileRefType (expr->base.type);
+	t = CompileRefType (obj, expr, expr->base.type);
 	if (amper)
 	{
 	    if (t)
@@ -2237,7 +2241,7 @@
 	if (!inst)
 	    break;
 	expr->base.type = s->symbol.type;
-	t = CompileRefType (expr->base.type);
+	t = CompileRefType (obj, expr, expr->base.type);
 	if (t)
 	{
 	    BuildInst (obj, OpUnFunc, inst, stat);
@@ -2412,7 +2416,7 @@
 	}
 	BuildInst (obj, OpDot, inst, stat);
 	inst->atom.atom = expr->tree.right->atom.atom;
-	t = CompileRefType (expr->base.type);
+	t = CompileRefType (obj, expr, expr->base.type);
 	if (t)
 	{
 	    BuildInst (obj, OpUnFunc, inst, stat);
@@ -2435,7 +2439,7 @@
 	}
 	BuildInst (obj, OpArrow, inst, stat);
 	inst->atom.atom = expr->tree.right->atom.atom;
-	t = CompileRefType (expr->base.type);
+	t = CompileRefType (obj, expr, expr->base.type);
 	if (t)
 	{
 	    BuildInst (obj, OpUnFunc, inst, stat);
@@ -2452,7 +2456,7 @@
     case AMPER:	    
 	obj = CompileLvalue (obj, expr->tree.left, stat, code, False, False, False, 
 			     False, True);
-	t = CompileRefType (expr->tree.left->base.type);
+	t = CompileRefType (obj, expr->tree.left, expr->tree.left->base.type);
 	if (!t)
 	    t = expr->tree.left->base.type;
 	expr->base.type = NewTypeRef (t, True);
@@ -4064,7 +4068,7 @@
 	    lvalue = NewExprAtom (decl->name, decl->symbol, False);
 	    *initObj = CompileLvalue (*initObj, lvalue,
 				       decls, code, False, True, True, 
-				      CompileRefType (s->symbol.type) != 0,
+				      CompileRefType (obj, lvalue, s->symbol.type) != 0,
 				      False);
 	    SetPush (*initObj);
 	    *initObj = CompileInit (*initObj, init, s->symbol.type, stat, code);




More information about the Commit mailing list