diff gen/tollvm.c @ 78:2332006e1fa4 trunk

[svn r82] Fixed: Fall-through switch cases were broken.
author lindquist
date Wed, 31 Oct 2007 20:50:21 +0100
parents 714057ff2dbb
children 3587401b6eeb
line wrap: on
line diff
--- a/gen/tollvm.c	Wed Oct 31 09:34:18 2007 +0100
+++ b/gen/tollvm.c	Wed Oct 31 20:50:21 2007 +0100
@@ -1241,12 +1241,20 @@
         }
     }
 
+    if (fnarg && paramtype && retval->getType() != paramtype) {
+        // this is unfortunately needed with the way SymOffExp is overused
+        // and static arrays can end up being a pointer to their element type
+        if (arg->field) {
+            retval = gIR->ir->CreateBitCast(retval, paramtype, "tmp");
+        }
+        else {
+            Logger::cout() << "got '" << *retval->getType() << "' expected '" << *paramtype << "'\n";
+            assert(0 && "parameter type that was actually passed is invalid");
+        }
+    }
+
     delete arg;
 
-    if (fnarg && paramtype && retval->getType() != paramtype) {
-        Logger::cout() << "got '" << *retval->getType() << "' expected '" << *paramtype << "'\n";
-        assert(0 && "parameter type that was actually passed is invalid");
-    }
     return retval;
 }