Skip to content

Commit 264de9c

Browse files
committed
Fix structure-returns.
1 parent 2b36a8e commit 264de9c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,14 @@ impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
16111611
}
16121612

16131613
alt (e) {
1614-
case (some[@ast.expr](_)) {
1614+
case (some[@ast.expr](?e)) {
1615+
if (typeck.type_is_structural(typeck.expr_ty(e))) {
1616+
// We usually treat structurals by-pointer; in particular,
1617+
// trans_expr will have given us a structure pointer. But in
1618+
// this case we're about to return. LLVM wants a first-class
1619+
// value here (which makes sense; the frame is going away!)
1620+
r.val = r.bcx.build.Load(r.val);
1621+
}
16151622
r.val = r.bcx.build.Ret(r.val);
16161623
ret r;
16171624
}

0 commit comments

Comments
 (0)