Skip to content

Commit

Permalink
added multiCondition sample
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 19, 2024
1 parent 5b81f94 commit 68e9feb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions samples/multiCondition/bad.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
static void f(bool b)
{
if (b) {}
else if (!b) {}
}

int main()
{
f(true);
return 0;
}
11 changes: 11 additions & 0 deletions samples/multiCondition/good.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
static void f(bool b)
{
if (b) {}
else {}
}

int main()
{
f(true);
return 0;
}
9 changes: 9 additions & 0 deletions samples/multiCondition/out.txt
Original file line number Diff line number Diff line change
@@ -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) {}
^

0 comments on commit 68e9feb

Please sign in to comment.