Skip to content

Commit 5959095

Browse files
committed
Add test for dead code messages (issue #94)
Automatic testing wasn't possible in #785 (comment), but is now with cram.
1 parent 6023cbd commit 5959095

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
3+
int main() {
4+
int x;
5+
if (1)
6+
x = 1;
7+
else
8+
x = 2;
9+
if (x)
10+
x = 1;
11+
else
12+
x = 2;
13+
assert(x > 1 && x < 0);
14+
}

tests/regression/issue-94.t/run.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ goblint --enable ana.dead-code.lines --enable ana.dead-code.branches issue-94.c
2+
[Error][Assert] Assertion "tmp" will fail. (issue-94.c:13:3-13:35)
3+
[Warning][Deadcode] Function 'main' has dead code:
4+
on line 8 (issue-94.c:8-8)
5+
on line 12 (issue-94.c:12-12)
6+
on line 14 (issue-94.c:14-14)
7+
[Warning][Deadcode] Logical lines of code (LLoC) summary:
8+
live: 6
9+
dead: 3
10+
total: 9
11+
[Warning][Deadcode][CWE-571] condition '1' is always true (issue-94.c:5:7-5:8)
12+
[Warning][Deadcode][CWE-571] condition 'x' is always true (issue-94.c:9:7-9:8)
13+
[Warning][Deadcode][CWE-570] condition 'x > 1' (possibly inserted by CIL) is always false (issue-94.c:13:3-13:35)

0 commit comments

Comments
 (0)