about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-12-08 15:52:01 -0800
committerGraydon Hoare <graydon@mozilla.com>2010-12-08 15:52:01 -0800
commit264de9c7fcffe265eb09dc992c3ba023dd45dc9a (patch)
treed90647626bc688cae0ff166a32dadd89c6c77630 /src/comp
parent2b36a8eab41a4e323f9c234ff89a46fbe2cd84d5 (diff)
downloadrust-264de9c7fcffe265eb09dc992c3ba023dd45dc9a.tar.gz
rust-264de9c7fcffe265eb09dc992c3ba023dd45dc9a.zip
Fix structure-returns.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 5e96f58e2b0..1c430419111 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1611,7 +1611,14 @@ impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
     }
 
     alt (e) {
-        case (some[@ast.expr](_)) {
+        case (some[@ast.expr](?e)) {
+            if (typeck.type_is_structural(typeck.expr_ty(e))) {
+                // We usually treat structurals by-pointer; in particular,
+                // trans_expr will have given us a structure pointer. But in
+                // this case we're about to return. LLVM wants a first-class
+                // value here (which makes sense; the frame is going away!)
+                r.val = r.bcx.build.Load(r.val);
+            }
             r.val = r.bcx.build.Ret(r.val);
             ret r;
         }