File: pointer_loop.i

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 (53 lines) | stat: -rw-r--r-- 783 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* run.config*
   COMMENT: this line preserves location...
 */
int base0=7;
int base1=1;
int base2=2;
int *base_p[2]={&base1,&base2};
int *Ctrl_p;
void main ()
{ short int i;
  int Elements = 2;

  for (i = 0; i < Elements; i++)
    {
      Ctrl_p = base_p[i];
      *Ctrl_p = 3+i;
      }
}


struct Ctrl;
typedef struct Slot {
  int Elements;
  struct Ctrl *const *Ctrl_p;
} Slot_t;
typedef struct Ctrl {
  const Slot_t *slot_p;
  int Status;
} Ctrl_t;

Ctrl_t Ctrl[2];
static Ctrl_t *const ACtrl[2] = {
  &Ctrl[0],
  &Ctrl[1]
};
const Slot_t Slot[2] = {
  { 2, &ACtrl[0]},
  { 0, (void *) 0}
};

void f(void)
{
  int i;
  int j;
  i=0;
  (Slot[i].Ctrl_p[0])->Status = 0;
  (Slot[i].Ctrl_p[1])->Status = 0;
  for(j = 0; j < 2; j++) {
    (Slot[i].Ctrl_p[j])->Status = 1;

    }

}