re PR c/33763 (Bogus inlining failed in call to `xxx': redefined extern inline functi...
[official-gcc.git] / gcc / testsuite / c-c++-common / pr33763.c
blobdbdfa77fc3d0c8131594cb1d8b1de191ba91e324
1 /* PR tree-optimization/33763 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
5 typedef struct
7 void *a;
8 void *b;
9 } T;
10 extern void *foo (const char *, const char *);
11 extern void *bar (void *, const char *, T);
12 extern int baz (const char *, int);
14 extern inline __attribute__ ((always_inline, gnu_inline)) int
15 baz (const char *x, int y)
17 return 2;
20 int
21 baz (const char *x, int y)
23 return 1;
26 int xa, xb;
28 static void *
29 inl (const char *x, const char *y)
31 T t = { &xa, &xb };
32 int *f = (int *) __builtin_malloc (sizeof (int));
33 const char *z;
34 int o = 0;
35 void *r = 0;
37 for (z = y; *z; z++)
39 if (*z == 'r')
40 o |= 1;
41 if (*z == 'w')
42 o |= 2;
44 if (o == 1)
45 *f = baz (x, 0);
46 if (o == 2)
47 *f = baz (x, 1);
48 if (o == 3)
49 *f = baz (x, 2);
51 if (o && *f > 0)
52 r = bar (f, "w", t);
53 return r;
56 void *
57 foo (const char *x, const char *y)
59 return inl (x, y);