Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a bug in the code generator that caused the result of switch st…

…atements to be undefined
  • Loading branch information...
commit 6906948c73f234abf974d57b7a9cd77883341134 1 parent 32153e8
@colinbenner authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/asmcomp/llvmcompile.ml
View
6 src/asmcomp/llvmcompile.ml
@@ -371,7 +371,11 @@ let rec helper in_tail_position in_try_block instr =
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 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";
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
Please sign in to comment.
Something went wrong with that request. Please try again.