File: select_by_annot.c

package info (click to toggle)
frama-c 20140301%2Bneon%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,548 kB
  • ctags: 28,183
  • sloc: ml: 181,252; ansic: 13,776; makefile: 2,452; sh: 1,085; lisp: 178
file content (151 lines) | stat: -rw-r--r-- 3,819 bytes parent folder | download | duplicates (2)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* run.config
   EXECNOW: make -s tests/slicing/select_by_annot.opt
   CMD: tests/slicing/select_by_annot.opt
   OPT: -deps -lib-entry -main main -journal-disable
   CMD: bin/toplevel.opt
   OPT: -check -deps -lib-entry -main main -slice-pragma main -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-assert main -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma modifS -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f1 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f2 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f3 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f4 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f5 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f6 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f7 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-loop-inv f8 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f8 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-assert f8 -no-slice-callers -journal-disable -then-on 'Slicing export' -print
   OPT: -check -deps -lib-entry -main main -slice-pragma f9 -no-slice-callers -journal-disable -then-on 'Slicing export' -print


*/
struct Tstr { int a; int b; } S;
int Sa ;

int f1(int cond) {
  int * p = &S.a ;
  if (cond) {
    //@ assert (cond != 0);
    Sa = *p ;
    }
  //@slice pragma expr *p;
  return Sa ;
}

int f2(int cond) {
  int * p = &S.a ;
  if (cond)
    //@ assert (cond != 0);
    Sa = *p ;
  //@slice pragma expr S.a;
  return Sa ;
}

int f3(int cond) {
  int * p = &S.a ;
  if (cond) {
    //@ slice pragma ctrl;
    Sa = *p ;
    }
  return Sa ;
}

int f4(int cond) {
  int * p = &S.a ;
  if (cond) {
    //@ slice pragma stmt;
    Sa = *p ;
    }
  return Sa ;
}

int f5(int cond) {
  int * p = &S.a ;
  if (cond) {
    //@ slice pragma expr 1;
    Sa = *p ;
    }
  return Sa ;
}

int f6(int cond) {
  int * p = &S.a ;
  //@ slice pragma stmt;
  if (cond) {
    Sa = *p ;
    Sa ++ ;
    }
  return Sa ;
}

int f7(int cond) {
  int * p = &S.a ;
  if (cond)
  //@ slice pragma stmt;
    {
      Sa = *p ;
      Sa ++ ;
    }
  return Sa ;
}


int f8(int cond) {
  int * p = &S.a ;
  //
  /*@ loop invariant cond >= 0 ;
    loop variant cond ; */
  while (cond)
    { //@ assert  cond <= \at(cond,Pre) ;
      //  assert S.a + cond == \at(S.a + cond,Pre) ;
      Sa = *p ;
      //@ slice pragma stmt;
      S.a ++ ;
      cond--;
    }
  return Sa ;
}

int X9, Y9, Z9 ;
void f9(int c1, int c2) {
  if (c1 > c2)
    goto L;
  c1 = c2 ;
  //@ slice pragma stmt;
  {L: X9 = c1 ;}
  Y9 = Z9 ;
  Z9 = c2 ;
}

void modifS (int a, int b) {
  S.a += a;
  S.b -= b;
  //@slice pragma expr S.a;
}
int new_int (void);
  int d;
int main (void) {
  int a = 0;
  int b = 0;
  int c = 0;
  if (d > 0) {
    //@ assert (b == 0);
    a = 1;
    }
  //@ slice pragma expr a+b;
  int x = a+b+c+d;
  modifS (a, b);
  // assert (d>0 => a == 1) && (!(d>0) => a==0);
  d = new_int ();
  f1(d) ;
  f2(d) ;
  f3(d) ;
  f4(d) ;
  f5(d) ;
  f6(d) ;
  f7(d) ;
  f8(d) ;
  f9(d,a) ;
  return x;
}