~ubuntu-branches/debian/sid/frama-c/sid

« back to all changes in this revision

Viewing changes to tests/spec/assigns.c

  • Committer: Bazaar Package Importer
  • Author(s): Mehdi Dogguy
  • Date: 2009-06-03 08:19:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090603081925-kihvxvt0wy3zc4ar
Tags: upstream-20081201.dfsg
ImportĀ upstreamĀ versionĀ 20081201.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
struct list {
 
2
  int hd;
 
3
  struct list *next;
 
4
};
 
5
 
 
6
/*@ predicate reachable{L}(struct list *root, struct list *to) =
 
7
  @   root == to || root != \null && reachable(root->next,to) ;
 
8
  @*/
 
9
 
 
10
//@ assigns *p;
 
11
void reset(int *p) { *p = 0; }
 
12
 
 
13
// three equivalent assigns clauses
 
14
//@ assigns t[0..n-1];
 
15
void reset_array1(int t[],int n) {
 
16
  int i;
 
17
  for (i=0; i < n; i++) t[i] = 0;
 
18
}
 
19
 
 
20
//@ assigns *(t+(0..n-1));
 
21
void reset_array2(int t[],int n) {
 
22
  int i;
 
23
  for (i=0; i < n; i++) t[i] = 0;
 
24
}
 
25
 
 
26
//@ assigns *(t+{ i | int i ; 0 <= i < n });
 
27
void reset_array3(int t[],int n) {
 
28
  int i;
 
29
  for (i=0; i < n; i++) t[i] = 0;
 
30
}
 
31
 
 
32
//@ assigns { q->hd | struct list *q ; reachable(p,q) };
 
33
void incr_list(struct list *p) {
 
34
  while (p) { p->hd++ ; p = p->next; }
 
35
}