| 1 |
/* { dg-do run } */ |
| 2 |
/* PR/107115 */ |
| 3 |
/* { dg-additional-options "-fno-schedule-insns -fno-schedule-insns2" } */ |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
void test1(long *p1) |
| 8 |
{ |
| 9 |
p1[0] = 1; |
| 10 |
} |
| 11 |
long test2(long long *p2, int index1, int index2) |
| 12 |
{ |
| 13 |
p2[index1] = 2; |
| 14 |
return p2[index2]; |
| 15 |
} |
| 16 |
long test3(long *p3, int index2, long value) |
| 17 |
{ |
| 18 |
p3[index2] = 3; |
| 19 |
p3[index2] = value; |
| 20 |
return p3[0]; |
| 21 |
} |
| 22 |
long test4(void *p4, int index1, int index2) |
| 23 |
{ |
| 24 |
test1(p4); |
| 25 |
long temp = test2(p4, index1, index2); |
| 26 |
return test3(p4, index2, temp); |
| 27 |
} |
| 28 |
long (*volatile vtest)(void *, int, int) = test4; |
| 29 |
int main(void) |
| 30 |
{ |
| 31 |
void *pp = malloc(sizeof (long) + sizeof(long long)); |
| 32 |
if (!pp) abort(); |
| 33 |
long result = vtest(pp, 0, 0); |
| 34 |
if (*(long *)pp != 2 || result != 2) |
| 35 |
__builtin_abort (); |
| 36 |
return 0; |
| 37 |
} |