1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
static void foo(int x)
{
__context__(0); // OK
__context__(x, 0); // OK
__context__ (x, 1); // OK
__context__(x); // KO: no const expr
__context__(1,x); // KO: no const expr
__context__; // KO: no expression at all
__context__(; // KO: no expression at all
__context__ 0; // KO: need parens
__context__ x, 0; // KO: need parens
__context__(x, 0; // KO: unmatched parens
__context__ x, 0); // KO: unmatched parens
__context__(0; // KO: unmatched parens
__context__ 0); // KO: unmatched parens
__context__(); // KO: no expression at all
__context__(,0); // KO: no expression at all
__context__(x,); // KO: no expression at all
__context__(,); // KO: no expression at all
}
/*
* check-name: context-stmt
* check-command: sparse -Wno-context $file
*
* check-error-start
context-stmt.c:10:20: error: Expected ( after __context__ statement
context-stmt.c:10:20: error: got ;
context-stmt.c:11:21: error: expression expected after '('
context-stmt.c:11:21: error: got ;
context-stmt.c:11:21: error: Expected ) at end of __context__ statement
context-stmt.c:11:21: error: got ;
context-stmt.c:13:21: error: Expected ( after __context__ statement
context-stmt.c:13:21: error: got 0
context-stmt.c:14:21: error: Expected ( after __context__ statement
context-stmt.c:14:21: error: got x
context-stmt.c:15:25: error: Expected ) at end of __context__ statement
context-stmt.c:15:25: error: got ;
context-stmt.c:16:21: error: Expected ( after __context__ statement
context-stmt.c:16:21: error: got x
context-stmt.c:17:22: error: Expected ) at end of __context__ statement
context-stmt.c:17:22: error: got ;
context-stmt.c:18:21: error: Expected ( after __context__ statement
context-stmt.c:18:21: error: got 0
context-stmt.c:20:21: error: expression expected after '('
context-stmt.c:20:21: error: got )
context-stmt.c:21:21: error: expression expected after '('
context-stmt.c:21:21: error: got ,
context-stmt.c:22:23: error: expression expected after ','
context-stmt.c:22:23: error: got )
context-stmt.c:23:21: error: expression expected after '('
context-stmt.c:23:21: error: got ,
context-stmt.c:23:22: error: expression expected after ','
context-stmt.c:23:22: error: got )
context-stmt.c:7:21: error: bad constant expression
context-stmt.c:8:23: error: bad constant expression
* check-error-end
*/
|