From 03387349dceaecd8feb708eb467a0bde372cb664 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 13 Sep 2018 17:38:09 +0100 Subject: C: Fix an issue with assigning to unitialized variables at end of blocks Assigning to an uninitialized variable as the last statement in a block is almost certainly a type, and if that occurs then the lift_assign re-write will introduce empty blocks causing this error to occur. Now when we see such an empty block when converting to A-normal form we turn it into unit, and emit a warning stating that an empty block has been found as well as the probable cause (uninitialized variable). --- test/c/anf_block.expect | 1 + test/c/anf_block.sail | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 test/c/anf_block.expect create mode 100644 test/c/anf_block.sail (limited to 'test/c') diff --git a/test/c/anf_block.expect b/test/c/anf_block.expect new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/c/anf_block.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/anf_block.sail b/test/c/anf_block.sail new file mode 100644 index 00000000..bd26f67a --- /dev/null +++ b/test/c/anf_block.sail @@ -0,0 +1,13 @@ + +val print = "print_endline" : string -> unit + +val main : unit -> unit + +function main() = { + match () { + _ => { + TEST = () + } + }; + print("ok") +} \ No newline at end of file -- cgit v1.2.3