From 57e69d964710593ccdee028104e9a5aa0b04760f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 19 Mar 2021 23:35:34 +0100 Subject: [PATCH] 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; +}