aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8.1/gcc/testsuite/gcc.dg/lto/20120723_0.c
blob: 78cfdf77c5bde2cd34f48d3c14a6bc6908e5c9be (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Make sure that by reference and by value aggregate jump functions do not get
   mixed up.
   ??? This testcase is invalid C and can only pass on specific platforms.  */
/* { dg-lto-do run } */
/* { dg-skip-if "" { { sparc*-*-* } && ilp32 } { "*" } { "" } } */
/* { dg-lto-options { {-O3 -fno-early-inlining -flto}} } */

extern void abort (void);

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

struct E
{
  struct S *p;
};

struct S *gs;
int gr = 111;
char gc[1024];

static __attribute__ ((noinline, noclone)) struct S *
get_s (void)
{
  return (struct S *) &gc;
}

static void wrong_target (struct S *s)
{
  abort ();
}

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

extern void foo (struct S *s);

int main (int argc, char **argv)
{
  struct S *s = get_s();
  gs = s;
  s->i = 5678;
  s->f = wrong_target;
  s->j = 1234;
  foo (s);

  return gr;
}