Debian Codegraph @

gcc/testsuite/gcc.c-torture/compile/20020706-2.c

raw
1 // Contributed by Alexandre Oliva <[email protected]>
2 // From Red Hat case 106165.
3
4 /* { dg-require-effective-target indirect_calls } */
5
6 typedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short);
7
8 void crashIt(int id, FUNC_P *func, unsigned char *funcparm)
9 {
10 unsigned char buff[5], reverse[4];
11 unsigned char *bp = buff;
12 unsigned char *rp = reverse;
13 unsigned short int count = 0;
14 unsigned short cnt;
15 while (id > 0)
16 {
17 *rp++ = (unsigned char) (id & 0x7F);
18 id >>= 7;
19 count++;
20 }
21 cnt = count + 1;
22 while ((count--) > 1)
23 {
24 *bp++ = (unsigned char)(*(--rp) | 0x80);
25 }
26 *bp++ = *(--rp);
27 (void)(*func)(funcparm, buff, cnt);
28 }