Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation of catches with multiple handlers #1973

Merged
merged 2 commits into from Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -8,6 +8,9 @@ Working version
- GPR#1579: Add a separate types for clambda primitives
(Pierre Chambart, review by Vincent Laviron and Mark Shinwell)

- GPR#1973: fix compilation of catches with multiple handlers
(Vincent Laviron)

- GPR#2228: refactoring the handling of .cmi files by moving it from
Env to a new module Persistent_env
(Gabriel Scherer, review by Jérémie Dimino and Thomas Refis)
Expand Down
3 changes: 2 additions & 1 deletion asmcomp/linearize.ml
Expand Up @@ -272,7 +272,8 @@ let rec linear i n =
let n2 = List.fold_left2 (fun n (_nfail, handler) lbl_handler ->
match handler.Mach.desc with
| Iend -> n
| _ -> cons_instr (Llabel lbl_handler) (linear handler n))
| _ -> cons_instr (Llabel lbl_handler)
(linear handler (add_branch lbl_end n)))
n1 handlers labels_at_entry_to_handlers
in
let n3 = linear body (add_branch lbl_end n2) in
Expand Down
20 changes: 20 additions & 0 deletions testsuite/tests/asmgen/catch-multiple.cmm
@@ -0,0 +1,20 @@
(* TEST
files = "main.c"
arguments = "-DINT_INT -DFUN=catch_multiple main.c"
* asmgen
*)

(*
Expected output:
catch_multiple(0) == -1
catch_multiple(1) == 1
*)

(function "catch_multiple" (b:int)
(let x
(catch
(if (== b 0) (exit zero)
(exit other))
with (zero) -1
and (other) ( * b b))
x))
1 change: 1 addition & 0 deletions testsuite/tests/asmgen/ocamltests
Expand Up @@ -2,6 +2,7 @@ arith.cmm
catch-rec.cmm
catch-try.cmm
catch-float.cmm
catch-multiple.cmm
catch-try-float.cmm
checkbound.cmm
even-odd-spill.cmm
Expand Down