aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
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 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;
}