From 57e69d964710593ccdee028104e9a5aa0b04760f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 19 Mar 2021 23:35:34 +0100 Subject: [PATCH 1/3] test related to pr #1425 --- test/val/pr1425.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/val/pr1425.c diff --git a/test/val/pr1425.c b/test/val/pr1425.c new file mode 100644 index 000000000..e3ae23ba3 --- /dev/null +++ b/test/val/pr1425.c @@ -0,0 +1,45 @@ + +/* pr #1425 - Ternary fixes */ + +unsigned char fails = 0; + +void test1(void) +{ + int x = 0; + x ? (void)x-- : (void)1; + if (x != 0) { + fails++; + } +} + +int test2(void) +{ + int x = 0, y = 0; + x ? (void)x--, (void)y++ : (void)1; + if (x != 0) { + fails++; + } + if (y != 0) { + fails++; + } +} + +void test3(void) +{ + int x = 0, y = 0; + x ? ((void)x--, (void)y++) : (void)1; + if (x != 0) { + fails++; + } + if (y != 0) { + fails++; + } +} + +int main(void) +{ + test1(); + test2(); + test3(); + return fails; +} From cc040ca04a861030de751c70a52dc2fcd2c06727 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 19 Mar 2021 23:39:56 +0100 Subject: [PATCH 2/3] remove, fucking git --- test/val/pr1425.c | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 test/val/pr1425.c diff --git a/test/val/pr1425.c b/test/val/pr1425.c deleted file mode 100644 index e3ae23ba3..000000000 --- a/test/val/pr1425.c +++ /dev/null @@ -1,45 +0,0 @@ - -/* pr #1425 - Ternary fixes */ - -unsigned char fails = 0; - -void test1(void) -{ - int x = 0; - x ? (void)x-- : (void)1; - if (x != 0) { - fails++; - } -} - -int test2(void) -{ - int x = 0, y = 0; - x ? (void)x--, (void)y++ : (void)1; - if (x != 0) { - fails++; - } - if (y != 0) { - fails++; - } -} - -void test3(void) -{ - int x = 0, y = 0; - x ? ((void)x--, (void)y++) : (void)1; - if (x != 0) { - fails++; - } - if (y != 0) { - fails++; - } -} - -int main(void) -{ - test1(); - test2(); - test3(); - return fails; -} From 82fb9aa41847d08556cfe12cc51a54a3ca2e2536 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 20 Mar 2021 00:55:55 +0100 Subject: [PATCH 3/3] testcase related to pr #1423 --- test/val/pr1423.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/val/pr1423.c diff --git a/test/val/pr1423.c b/test/val/pr1423.c new file mode 100644 index 000000000..3135b64a3 --- /dev/null +++ b/test/val/pr1423.c @@ -0,0 +1,41 @@ +/* pr #1423 - Codegen fix for certain cases of object addresses as boolean */ + +unsigned char fails = 0; + +void test1(void) +{ + int a; + while (&a) { + return; + } + fails++; + return; +} + +void test2(void) +{ + int a; + do { + return; + } while (&a); + fails++; + return; +} + +void test3(void) +{ + int a; + for (;&a;) { + return; + } + fails++; + return; +} + +int main(void) +{ + test1(); + test2(); + test3(); + return fails; +}