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) {} + ^