File: ptr_call_object.c

package info (click to toggle)
frama-c 20220511-manganese-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 66,492 kB
  • sloc: ml: 278,834; ansic: 47,093; sh: 4,823; makefile: 3,613; javascript: 2,436; python: 1,919; perl: 897; lisp: 293; xml: 62
file content (37 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (3)
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
/* run.config*
   STDOPT: +"-eva-slevel 2"
*/

struct obj {
  int (*next)();
  int i;
};

int next_1(struct obj *p, struct obj s) {
  Frama_C_show_each_p_in_next_1(p, s);
  return 1;
}
 
int next_0(struct obj *p, struct obj s) {
  Frama_C_show_each_p_in_next_0(p, s);
  return 0;
}

//@ assigns \result \from \nothing;
int rand(void);

int main() {
  struct obj o1, o0;
  struct obj *p;
  
  o1.next = &next_1;
  o0.next = &next_0;
 
  p = rand () ? &o1 : &o0;
  
  //@slevel merge;
    
  if (p->next(p, *p)){  // p must be precise in each call, including as a formal
    Frama_C_show_each_x(p); // only p == &o1 is possible
  }
}