aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/pr33763.c
blob: dbdfa77fc3d0c8131594cb1d8b1de191ba91e324 (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
55
56
57
58
59
60
/* PR tree-optimization/33763 */
/* { dg-do compile } */
/* { dg-options "-O2" } */

typedef struct
{
  void *a;
  void *b;
} T;
extern void *foo (const char *, const char *);
extern void *bar (void *, const char *, T);
extern int baz (const char *, int);

extern inline __attribute__ ((always_inline, gnu_inline)) int
baz (const char *x, int y)
{
  return 2;
}

int
baz (const char *x, int y)
{
  return 1;
}

int xa, xb;

static void *
inl (const char *x, const char *y)
{
  T t = { &xa, &xb };
  int *f = (int *) __builtin_malloc (sizeof (int));
  const char *z;
  int o = 0;
  void *r = 0;

  for (z = y; *z; z++)
    {
      if (*z == 'r')
	o |= 1;
      if (*z == 'w')
	o |= 2;
    }
  if (o == 1)
    *f = baz (x, 0);
  if (o == 2)
    *f = baz (x, 1);
  if (o == 3)
    *f = baz (x, 2);

  if (o && *f > 0)
    r = bar (f, "w", t);
  return r;
}

void *
foo (const char *x, const char *y)
{
  return inl (x, y);
}