aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr46076.c
blob: 6e5907b499599c2e47c0e3fa5c9790146060f1a5 (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
/* { dg-do link } */
/* { dg-options "-O2" } */

extern void link_error (void);

typedef unsigned char(*Calculable)(void);

static unsigned char one() { return 1; }
static unsigned char two() { return 2; }

static int
print(Calculable calculate)
{
  return calculate() + calculate() + 1;
}

int
main()
{
  /* Make sure we perform indirect inlining of one and two and optimize
     the result to a constant.  */
  for (int i = 0; i < 100; i++)
    {
      if (print(one) != 3)
	link_error ();
      if (print(two) != 5)
	link_error ();
    }
  return 0;
}