/* { 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); } issues bogus sorry diagnostics, while simpler testcases are handled just fine: extern int foo (const char *, int); 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 int inl (const char *x, int y) { return baz (x, y); } int foo (const char *x, int y) { return inl (x, y); } When a gnu_inline (or extern inline gnu89) function has a real is redefined, we don't want any inlining for that function even if it is always_inline, at least GCC always behaved that way and even on the simpler testcase behaves that way. Even the original testcase works just fine with GCC 3.2.x, so this is a regression. On the trunk it is enough to e.g. remove one of the 3 baz calls in inl and it compiles just fine (none of the baz calls is inlined as expected), but e.g. on 4.1 branch the compilation still fails. arts hits this problem when building against recent glibcs. -- Summary: [4.1/4.2/4.3 Regression] Bogus inlining failed in call to `xxx': redefined extern inline functions are not considered for inlining Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33763