File: pr90553.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (128 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* { dg-do run } */

__attribute__((__noipa__))
void f1(int x, void (*p1 []) (int, int))
{
  int i;
  for (i = 0; i < x; i++)
    p1[i](42, 666);
}

int z1_called = 0;
int w1_called = 0;

__attribute__((__noipa__))
void z1(int a, int b)
{
  if (w1_called || z1_called)
    __builtin_abort();
  z1_called++;
}

__attribute__((__noipa__))
void w1(int a, int b)
{
  if (w1_called || !z1_called)
    __builtin_abort();
  w1_called++;
}

int z2_called = 0;
int w2_called = 0;

__attribute__((__noipa__))
void z2(void)
{
  if (w2_called || z2_called)
    __builtin_abort();
  z2_called++;
}

__attribute__((__noipa__))
void w2(void)
{
  if (w2_called || !z2_called)
    __builtin_abort();
  w2_called++;
}

void (*p2 []) () = { w2, z2 };

__attribute__((__noipa__))
void f2(int x)
{
  void (**q) (void) = p2 + x;
  int i;
  for (i = 0; i < x; i++)
    (*(--q))();
}

__attribute__((__noipa__))
void f3(int x, int (*p3 []) (int))
{
  int i;
  int next = x;
  for (i = 0; i < x; i++)
    next = p3[i](next);
}

int z3_called = 0;
int w3_called = 0;

__attribute__((__noipa__))
int z3(int a)
{
  if (w3_called || z3_called || a != 2)
    __builtin_abort();
  z3_called++;
  return 42;
}

__attribute__((__noipa__))
int w3(int a)
{
  if (w3_called || !z3_called || a != 42)
    __builtin_abort();
  w3_called++;
  return 4096;
}

int (*p4 []) (int) = { z3, w3 };

__attribute__((__noipa__))
void f4(int x)
{
  int (**q) (int) = p4;
  int (**r) (int) = p4 + x;

  int next = x;
  for (; q < r; q++)
    next = (*q)(next);
}

int main(void)
{
  static int (*p3 []) (int) = { z3, w3 };

  static void (*p1 []) (int, int) = { z1, w1 };

  f1(2, p1);
  if (z1_called != 1 || w1_called != 1)
    __builtin_abort();

  f2(2);
  if (z2_called != 1 || w2_called != 1)
    __builtin_abort();

  f3(2, p3);
  if (z3_called != 1 || w3_called != 1)
    __builtin_abort();

  z3_called = 0;
  w3_called = 0;
  f4(2);
  if (z3_called != 1 || w3_called != 1)
    __builtin_abort();

  __builtin_exit(0);
}