File: context-statement.c

package info (click to toggle)
sparse 0.4.1%2Bgit20081218-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 1,348 kB
  • ctags: 2,852
  • sloc: ansic: 25,201; perl: 236; makefile: 181; sh: 181
file content (69 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download
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
63
64
65
66
67
68
69
#define a() __context__(LOCK, 1)
#define r() __context__(LOCK, -1)
#define m() __context__(LOCK, 0, 1)
#define m2() __context__(LOCK, 0, 2)

static void good_ar(void)
{
    a();
    r();
}

static void bad_arr(void)
{
    a();
    r();
    r();
}

static void good_macro1(void)
{
    a();
    m();
    r();
}

static void good_macro2(void)
{
    a();
    a();
    m();
    m2();
    r();
    r();
}

static void bad_macro1(void)
{
    m();
    a();
    r();
}

static void bad_macro2(void)
{
    a();
    r();
    m();
}

static void bad_macro3(void)
{
    r();
    a();
}

/*
 * check-name: Check __context__ statement with required context
 *
 * check-error-start
context-statement.c:16:8: warning: context imbalance in 'bad_arr': unexpected unlock
context-statement.c:16:8:    context 'LOCK': wanted 0, got -1
context-statement.c:38:5: warning: context imbalance in 'bad_macro1': __context__ statement expected different context
context-statement.c:38:5:    context 'LOCK': wanted >= 1, got 0
context-statement.c:47:5: warning: context imbalance in 'bad_macro2': __context__ statement expected different context
context-statement.c:47:5:    context 'LOCK': wanted >= 1, got 0
context-statement.c:53:5: warning: context imbalance in 'bad_macro3': __context__ statement expected different context
context-statement.c:53:5:    context 'LOCK': wanted >= 0, got -1
 * check-error-end
 */