From 68e9feb0c2af3e36a99febd88b5e888fdde69323 Mon Sep 17 00:00:00 2001 From: firewave Date: Mon, 12 Aug 2024 17:27:03 +0200 Subject: [PATCH] added `multiCondition` sample --- samples/multiCondition/bad.c | 11 +++++++++++ samples/multiCondition/good.c | 11 +++++++++++ samples/multiCondition/out.txt | 9 +++++++++ 3 files changed, 31 insertions(+) create mode 100644 samples/multiCondition/bad.c create mode 100644 samples/multiCondition/good.c create mode 100644 samples/multiCondition/out.txt diff --git a/samples/multiCondition/bad.c b/samples/multiCondition/bad.c new file mode 100644 index 00000000000..dd352a189bf --- /dev/null +++ b/samples/multiCondition/bad.c @@ -0,0 +1,11 @@ +static void f(bool b) +{ + if (b) {} + else if (!b) {} +} + +int main() +{ + f(true); + return 0; +} diff --git a/samples/multiCondition/good.c b/samples/multiCondition/good.c new file mode 100644 index 00000000000..715844f85ca --- /dev/null +++ b/samples/multiCondition/good.c @@ -0,0 +1,11 @@ +static void f(bool b) +{ + if (b) {} + else {} +} + +int main() +{ + f(true); + return 0; +} \ No newline at end of file diff --git a/samples/multiCondition/out.txt b/samples/multiCondition/out.txt new file mode 100644 index 00000000000..8753c103594 --- /dev/null +++ b/samples/multiCondition/out.txt @@ -0,0 +1,9 @@ +samples\multiCondition\bad.c:4:14: style: Expression is always true because 'else if' condition is opposite to previous condition at line 3. [multiCondition] + else if (!b) {} + ^ +samples\multiCondition\bad.c:3:9: note: first condition + if (b) {} + ^ +samples\multiCondition\bad.c:4:14: note: else if condition is opposite to first condition + else if (!b) {} + ^