summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr40718.c
blob: f6029ed98ab75a174d7fae0fe91cb59bdff57552 (plain)
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
/* { dg-do run } */
/* { dg-require-effective-target ilp32 } */
/* { dg-options "-O1 -foptimize-sibling-calls" } */

void abort (void);

struct S
{
  void (__attribute__((__stdcall__)) *f) (struct S *);
  int i;
};

void __attribute__((__stdcall__))
foo (struct S *s)
{
  s->i++;
}

void __attribute__((__stdcall__))
bar (struct S *s)
{
  foo(s);
  s->f(s);
}

int main (void)
{
  struct S s = { foo, 0 };

  bar (&s);
  if (s.i != 2)
    abort ();

  return 0;
}