1/* PR middle-end/22127 */
2/* Testcase by <akr@m17n.org> */
3
4/* { dg-do run { target *-*-solaris2.* } } */
5/* { dg-require-effective-target ilp32 } */
6/* { dg-options "-O" } */
7
8typedef unsigned int size_t;
9extern int printf(const char *, ...);
10typedef unsigned char uint8_t;
11typedef unsigned int uint32_t;
12typedef unsigned int uint_t;
13typedef char *caddr_t;
14typedef int greg_t;
15typedef greg_t gregset_t[19];
16struct rwindow {
17 greg_t rw_local[8];
18 greg_t rw_in[8];
19};
20typedef struct gwindows {
21 int wbcnt;
22 greg_t *spbuf[31];
23 struct rwindow wbuf[31];
24} gwindows_t;
25struct fpu {
26 union {
27  uint32_t fpu_regs[32];
28  double fpu_dregs[16];
29 } fpu_fr;
30 struct fq *fpu_q;
31 uint32_t fpu_fsr;
32 uint8_t fpu_qcnt;
33 uint8_t fpu_q_entrysize;
34 uint8_t fpu_en;
35};
36typedef struct fpu fpregset_t;
37typedef struct {
38 unsigned int xrs_id;
39 caddr_t xrs_ptr;
40} xrs_t;
41typedef struct {
42 gregset_t gregs;
43 gwindows_t *gwins;
44 fpregset_t fpregs;
45 xrs_t xrs;
46 long filler[19];
47} mcontext_t;
48typedef struct {
49 unsigned int __sigbits[4];
50} sigset_t;
51typedef struct sigaltstack {
52 void *ss_sp;
53 size_t ss_size;
54 int ss_flags;
55} stack_t;
56typedef struct ucontext ucontext_t;
57struct ucontext {
58 uint_t uc_flags;
59 ucontext_t *uc_link;
60 sigset_t uc_sigmask;
61 stack_t uc_stack;
62 mcontext_t uc_mcontext;
63 long uc_filler[23];
64};
65extern int getcontext(ucontext_t *);
66extern int setcontext(const ucontext_t *);
67
68int flag;
69ucontext_t cont;
70int pad[100];
71typedef void (*fun_t)(int);
72fun_t p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12;
73
74int global;
75
76extern void abort(void);
77
78void h1(int v)
79{
80  global = v;
81}
82
83void h2(int v)
84{
85  if (v != 1)
86    abort();
87}
88
89void f(void)
90{
91  flag = 1;
92  setcontext(&cont);
93}
94
95int g(void)
96{
97  int ret;
98
99  flag = 0;
100  getcontext(&cont);
101  ret = flag;
102  if (ret == 0) {
103    h1 (flag);
104    p0 = p1 = p2 = p3 = p4 = p5 = p6 = p7 = p8 = h1;
105    f();
106    p0(ret); p1(ret); p2(ret); p3(ret); p4(ret); p5(ret); p6(ret); p7(ret); p8(ret);
107  }
108  else {
109    h2 (flag);
110  }
111  return ret;
112}
113
114int main(void)
115{
116  g();
117  return 0;
118}
119