Issue 24, drop output slot when not initializing. Un-XFAIL generic-tag.rs. Add test for output slot modes with several broken cases.

This commit is contained in:
Graydon Hoare 2010-06-24 13:32:59 -07:00
parent 69a34503f4
commit af44ec2856
3 changed files with 69 additions and 7 deletions

View File

@ -321,7 +321,6 @@ TEST_XFAILS_X86 := test/run-pass/mlist-cycle.rs \
test/run-pass/vec-slice.rs \
test/run-pass/generic-fn-infer.rs \
test/run-pass/generic-recursive-tag.rs \
test/run-pass/generic-tag.rs \
test/run-pass/bind-obj-ctor.rs \
test/run-pass/task-comm.rs \
test/compile-fail/rec-missing-fields.rs \
@ -391,6 +390,7 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \
obj-dtor.rs \
obj-with-vec.rs \
opeq.rs \
output-slot-variants.rs \
preempt.rs \
pred.rs \
readalias.rs \

View File

@ -3708,7 +3708,7 @@ let trans_visitor
and trans_prepare_call
((*initializing*)_:bool)
(initializing:bool)
(logname:(unit -> string))
(call:call)
: Il.operand =
@ -3718,11 +3718,15 @@ let trans_visitor
(Printf.sprintf "copy args for call to %s" (logname ())));
copy_fn_args false CLONE_none call;
iflog (fun _ -> annotate (Printf.sprintf "call %s" (logname ())));
(* FIXME (issue #24): we need to actually handle writing to an
* already-initialised slot. Currently we blindly assume we're
* initializing, overwrite the slot; this is ok if we're writing
* to an interior output slot, but we'll leak any exteriors as we
* do that. *)
if not initializing
then
begin
match call.call_callee_ty with
Ast.TY_fn (tsig, _) ->
drop_slot (get_ty_params_of_current_frame()) call.call_output
tsig.Ast.sig_output_slot None;
| _ -> bug () "calling non-fn"
end;
callee_fptr
and callee_drop_slot

View File

@ -0,0 +1,58 @@
fn ret_int_i() -> int {
ret 10;
}
fn ret_ext_i() -> @int {
ret 10;
}
fn ret_int_tup() -> tup(int,int) {
ret tup(10, 10);
}
fn ret_ext_tup() -> @tup(int,int) {
ret tup(10, 10);
}
fn ret_ext_mem() -> tup(@int, @int) {
ret tup(@10, @10);
}
fn ret_ext_ext_mem() -> @tup(@int, @int) {
ret tup(@10, @10);
}
fn main() {
let int int_i;
let @int ext_i;
let tup(int,int) int_tup;
let @tup(int,int) ext_tup;
let tup(@int,@int) ext_mem;
let @tup(@int,@int) ext_ext_mem;
int_i = ret_int_i(); // initializing
int_i = ret_int_i(); // non-initializing
int_i = ret_int_i(); // non-initializing
//ext_i = ret_ext_i(); // initializing
//ext_i = ret_ext_i(); // non-initializing
//ext_i = ret_ext_i(); // non-initializing
int_tup = ret_int_tup(); // initializing
int_tup = ret_int_tup(); // non-initializing
int_tup = ret_int_tup(); // non-initializing
//ext_tup = ret_ext_tup(); // initializing
//ext_tup = ret_ext_tup(); // non-initializing
//ext_tup = ret_ext_tup(); // non-initializing
ext_mem = ret_ext_mem(); // initializing
ext_mem = ret_ext_mem(); // non-initializing
ext_mem = ret_ext_mem(); // non-initializing
//ext_ext_mem = ret_ext_ext_mem(); // initializing
//ext_ext_mem = ret_ext_ext_mem(); // non-initializing
//ext_ext_mem = ret_ext_ext_mem(); // non-initializing
}