aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-08 15:52:01 -0800
committerGraydon Hoare <[email protected]>2010-12-08 15:52:01 -0800
commit264de9c7fcffe265eb09dc992c3ba023dd45dc9a (patch)
treed90647626bc688cae0ff166a32dadd89c6c77630
parentFix log upcall translation bug. Un-XFAIL rec-auto.rs. (diff)
downloadrust-264de9c7fcffe265eb09dc992c3ba023dd45dc9a.tar.xz
rust-264de9c7fcffe265eb09dc992c3ba023dd45dc9a.zip
Fix structure-returns.
-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 5e96f58e..1c430419 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;
}