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

« back to all changes in this revision

Viewing changes to tests/misc/fptr.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
   GCC:
 
3
   OPT: -memory-footprint 1 -val -deps -out  -journal-disable
 
4
   OPT: -memory-footprint 1 -val -deps -out -main main_uninit -journal-disable
 
5
   OPT: -memory-footprint 1 -val -deps -out -main main_alarm -journal-disable
 
6
*/
 
7
int R=77;
 
8
 
 
9
int f(int (*ptr(int x))) {
 
10
  R = ptr(1);
 
11
  return R;
 
12
}
 
13
 
 
14
int X=77,XH=0,XHH=0;
 
15
 
 
16
int h (int y) {X = y; XH= y; return X;} ;
 
17
int hh (int y) {X = y+y; XHH = y; return X;} ;
 
18
 
 
19
extern int hhh(int y);
 
20
 
 
21
typedef int (* PTR_FCT)(int);
 
22
typedef PTR_FCT TYPE[10];
 
23
TYPE GLOBAL;
 
24
int G;
 
25
void main0 (int c)
 
26
{
 
27
  int i=0;
 
28
//  i=c?i:i+1;
 
29
  GLOBAL[0] = h;
 
30
  GLOBAL[1] = hh;
 
31
// X=5;
 
32
  G=3;
 
33
  G=f(c?&h:&hh);
 
34
  G=f(&hhh);
 
35
}
 
36
 
 
37
void main (int c)
 
38
{
 
39
  int i=0;
 
40
  GLOBAL[0] = h;
 
41
  GLOBAL[1] = hh;
 
42
  for(i=0;i<3;i++) {
 
43
    CEA_F(GLOBAL[i]);
 
44
    G=f(GLOBAL[i]);
 
45
  }
 
46
}
 
47
 
 
48
void main_uninit (int c)
 
49
{
 
50
  int i=0;
 
51
  volatile int j=0;
 
52
  GLOBAL[2]=j;
 
53
  GLOBAL[0] = h;
 
54
  GLOBAL[1] = hh;
 
55
  for(i=0;i<3;i++) {
 
56
    CEA_F(GLOBAL[i]);
 
57
    G=f(GLOBAL[i]);
 
58
  }
 
59
}
 
60
 
 
61
int main_alarm(int c)
 
62
{
 
63
  PTR_FCT p = c ? &h : &hh;
 
64
  return (*p)(1/c);
 
65
}