Skip to content

Commit

Permalink
Add test for dead code messages (issue #94)
Browse files Browse the repository at this point in the history
Automatic testing wasn't possible in #785 (comment),
but is now with cram.
  • Loading branch information
sim642 committed Oct 5, 2022
1 parent 6023cbd commit 5959095
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/regression/issue-94.t/issue-94.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <assert.h>

int main() {
int x;
if (1)
x = 1;
else
x = 2;
if (x)
x = 1;
else
x = 2;
assert(x > 1 && x < 0);
}
13 changes: 13 additions & 0 deletions tests/regression/issue-94.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ goblint --enable ana.dead-code.lines --enable ana.dead-code.branches issue-94.c
[Error][Assert] Assertion "tmp" will fail. (issue-94.c:13:3-13:35)
[Warning][Deadcode] Function 'main' has dead code:
on line 8 (issue-94.c:8-8)
on line 12 (issue-94.c:12-12)
on line 14 (issue-94.c:14-14)
[Warning][Deadcode] Logical lines of code (LLoC) summary:
live: 6
dead: 3
total: 9
[Warning][Deadcode][CWE-571] condition '1' is always true (issue-94.c:5:7-5:8)
[Warning][Deadcode][CWE-571] condition 'x' is always true (issue-94.c:9:7-9:8)
[Warning][Deadcode][CWE-570] condition 'x > 1' (possibly inserted by CIL) is always false (issue-94.c:13:3-13:35)

0 comments on commit 5959095

Please # to comment.