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

« back to all changes in this revision

Viewing changes to tests/scope/zones.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
/* run.config
 
2
   EXECNOW: make -s tests/scope/zones.opt
 
3
   CMD: tests/scope/zones.opt
 
4
   OPT: -val -journal-disable
 
5
*/
 
6
 
 
7
/* bin/viewer.opt -val tests/scope/zones.c */
 
8
 
 
9
int T [10];
 
10
struct Tstr { int a; int b; } S;
 
11
int X,Y,Z;
 
12
 
 
13
int simple (int x, int y, int z) {
 
14
  y = 3; //no need for y before
 
15
  x ++; //not used
 
16
  x = y + z;
 
17
  return x;
 
18
}
 
19
 
 
20
int array1 (int x, int y) {
 
21
  T[x] = 3;
 
22
  T[0] += y;
 
23
  return T[0];
 
24
}
 
25
 
 
26
int struct1 (int x, int y) {
 
27
  struct Tstr s;
 
28
  s = S; // lose precision : even if we need s.b after, we need S before
 
29
  s.a = x;
 
30
  s.b += y;
 
31
  return s.a;
 
32
}
 
33
 
 
34
int ctrl1 (int x, int y, int z) {
 
35
  int a;
 
36
  if (x) {
 
37
    a = y;
 
38
    goto Lt2; // to keep Lt2
 
39
    Lt2 : ;
 
40
  }
 
41
  else {
 
42
    a = z;
 
43
  }
 
44
  return a;
 
45
}
 
46
 
 
47
//================================================================
 
48
 
 
49
int Xf, Xg, Yf, Yg;
 
50
 
 
51
int f (int x, int y, int z) {
 
52
  Xf += x;
 
53
  Yf = z;
 
54
  return x + y;
 
55
}
 
56
 
 
57
int g (int a, int b, int c) {
 
58
  Xg += b;
 
59
  Yg = c;
 
60
  return a + b;
 
61
}
 
62
 
 
63
int caller (int cond, int t, int u, int v) {
 
64
  int x1 = 0, y1 = 0, z1 = 0, a1 = 0, b1 = 0, c1 = 0;
 
65
  int (*pf)(int, int) = cond ? &f : &g;
 
66
  f(x1, y1, z1);
 
67
  g(a1, b1, c1);
 
68
  return (*pf)(t, u, v);
 
69
}
 
70
//================================================================
 
71
 
 
72
int main (int x, int y, int z) {
 
73
  simple (x, y, z);
 
74
  array1 (x, y);
 
75
  struct1 (x, y);
 
76
  ctrl1 (x, y, z);
 
77
 
 
78
  caller (x, x, y, z);
 
79
 
 
80
  return 0;
 
81
}