Skip to content

Commit

Permalink
Fixed a bug in the code generator that caused the result of switch st…
Browse files Browse the repository at this point in the history
…atements to be undefined
  • Loading branch information
colinbenner committed Jan 1, 2012
1 parent 32153e8 commit 6906948
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/asmcomp/llvmcompile.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ let rec helper in_tail_position in_try_block instr =
let c = c () in let c = c () in
let typ = try typeof (List.find (fun x -> typeof x != Void) (Array.to_list exprs)) with Not_found -> Void in let typ = try typeof (List.find (fun x -> typeof x != Void) (Array.to_list exprs)) with Not_found -> Void in
let value = alloca ("switch_res" ^ c) (if typ != Void then typ else int_type) @@ helper false in_try_block expr in let value = alloca ("switch_res" ^ c) (if typ != Void then typ else int_type) @@ helper false in_try_block expr in
let create_block lbl expr = Llabel (lbl ^ "." ^ c) @@ expr @@ Lbr ("end." ^ c) in let create_block lbl expr =
Llabel (lbl ^ "." ^ c)
@@ (if typeof expr != Void then store expr (Lvar("%switch_res" ^ c, Address typ)) else Lnothing)
@@ Lbr ("end." ^ c)
in
add_const "caml_exn_Match_failure"; add_const "caml_exn_Match_failure";
let default = create_block "default" (Lcaml_raise_exn(Lvar("@caml_exn_Match_failure", addr_type))) in let default = create_block "default" (Lcaml_raise_exn(Lvar("@caml_exn_Match_failure", addr_type))) in
let blocks = Array.mapi (fun i expr -> create_block ("case" ^ string_of_int i) expr) exprs in let blocks = Array.mapi (fun i expr -> create_block ("case" ^ string_of_int i) expr) exprs in
Expand Down

0 comments on commit 6906948

Please sign in to comment.