From 5bbcf6a723a45989e0a189a30e663a4d38b5f006 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 2 Dec 2014 01:44:49 +0100 Subject: mds-kbdc: dead code elimination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .../alive-code/for-for-break-end-alive | 25 ++++++++++++++++++++++ .../eliminate-dead-code/dead-code/for-break-dead | 14 ++++++++++++ .../for-if-continue-else-continue-end-dead | 25 ++++++++++++++++++++++ .../dead-code/function-for-return-end-dead | 20 +++++++++++++++++ .../dead-code/macro-for-return-end-dead | 20 +++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 test-files/mds-kbdc/eliminate-dead-code/alive-code/for-for-break-end-alive create mode 100644 test-files/mds-kbdc/eliminate-dead-code/dead-code/for-break-dead create mode 100644 test-files/mds-kbdc/eliminate-dead-code/dead-code/for-if-continue-else-continue-end-dead create mode 100644 test-files/mds-kbdc/eliminate-dead-code/dead-code/function-for-return-end-dead create mode 100644 test-files/mds-kbdc/eliminate-dead-code/dead-code/macro-for-return-end-dead (limited to 'test-files/mds-kbdc') diff --git a/test-files/mds-kbdc/eliminate-dead-code/alive-code/for-for-break-end-alive b/test-files/mds-kbdc/eliminate-dead-code/alive-code/for-for-break-end-alive new file mode 100644 index 0000000..6523352 --- /dev/null +++ b/test-files/mds-kbdc/eliminate-dead-code/alive-code/for-for-break-end-alive @@ -0,0 +1,25 @@ +for 1 to 2 as \1 + for 1 to 2 as \2 + break + end for + : "code" +end for + +# (for (@ 1 0-3) ‘1’ ‘2’ (.variable ‘\1’) +# (.inner +# (for (@ 2 2-5) ‘1’ ‘2’ (.variable ‘\2’) +# (.inner +# (break (@ 3 4-9)) +# ) +# ) +# (map (@ 5 2-2) +# (.sequence +# (keys (@ 5 2-9) ‘’) +# ) +# (.result +# (string (@ 5 12-18) ‘"code"’) +# ) +# ) +# ) +# ) + diff --git a/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-break-dead b/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-break-dead new file mode 100644 index 0000000..f8037a3 --- /dev/null +++ b/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-break-dead @@ -0,0 +1,14 @@ +for 1 to 2 as \1 + break + break +end for + +# (for (@ 1 0-3) ‘1’ ‘2’ (.variable ‘\1’) +# (.inner +# (break (@ 2 2-7)) +# ) +# ) +# :3:2–7: warning: statement is unreachable +# break +# ^^^^^ + diff --git a/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-if-continue-else-continue-end-dead b/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-if-continue-else-continue-end-dead new file mode 100644 index 0000000..108c7b0 --- /dev/null +++ b/test-files/mds-kbdc/eliminate-dead-code/dead-code/for-if-continue-else-continue-end-dead @@ -0,0 +1,25 @@ +for 1 to 2 as \1 + if 1 + continue + else + continue + end if + : "dead code" +end for + +# (for (@ 1 0-3) ‘1’ ‘2’ (.variable ‘\1’) +# (.inner +# (if (@ 2 2-4) ‘1’ +# (.inner +# (continue (@ 3 4-12)) +# ) +# (.otherwise +# (continue (@ 5 4-12)) +# ) +# ) +# ) +# ) +# :7:2–2: warning: statement is unreachable +# : "dead code" +# + diff --git a/test-files/mds-kbdc/eliminate-dead-code/dead-code/function-for-return-end-dead b/test-files/mds-kbdc/eliminate-dead-code/dead-code/function-for-return-end-dead new file mode 100644 index 0000000..39fb763 --- /dev/null +++ b/test-files/mds-kbdc/eliminate-dead-code/dead-code/function-for-return-end-dead @@ -0,0 +1,20 @@ +function f/0 + for 1 to 1 as \1 + return + end for + "dead code" +end function + +# (function (@ 1 0-8) ‘f/0’ +# (.inner +# (for (@ 2 2-5) ‘1’ ‘1’ (.variable ‘\1’) +# (.inner +# (return (@ 3 4-10)) +# ) +# ) +# ) +# ) +# :5:2–2: warning: statement is unreachable +# "dead code" +# + diff --git a/test-files/mds-kbdc/eliminate-dead-code/dead-code/macro-for-return-end-dead b/test-files/mds-kbdc/eliminate-dead-code/dead-code/macro-for-return-end-dead new file mode 100644 index 0000000..eb8fdaa --- /dev/null +++ b/test-files/mds-kbdc/eliminate-dead-code/dead-code/macro-for-return-end-dead @@ -0,0 +1,20 @@ +macro m/0 + for 1 to 1 as \1 + return + end for + : "dead code" +end macro + +# (macro (@ 1 0-5) ‘m/0’ +# (.inner +# (for (@ 2 2-5) ‘1’ ‘1’ (.variable ‘\1’) +# (.inner +# (return (@ 3 4-10)) +# ) +# ) +# ) +# ) +# :5:2–2: warning: statement is unreachable +# : "dead code" +# + -- cgit v1.2.3-70-g09d2