diff -p -up gcc-4.4-20090223/gcc/testsuite/g++.dg/opt/inline13.C.pr33763 gcc-4.4-20090223/gcc/testsuite/g++.dg/opt/inline13.C --- gcc-4.4-20090223/gcc/testsuite/g++.dg/opt/inline13.C.pr33763 2009-03-14 20:12:48.433347769 -0400 +++ gcc-4.4-20090223/gcc/testsuite/g++.dg/opt/inline13.C 2009-03-14 20:12:48.433347769 -0400 @@ -0,0 +1,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); +} diff -p -up gcc-4.4-20090223/gcc/testsuite/gcc.dg/pr33763.c.pr33763 gcc-4.4-20090223/gcc/testsuite/gcc.dg/pr33763.c --- gcc-4.4-20090223/gcc/testsuite/gcc.dg/pr33763.c.pr33763 2009-03-14 20:12:48.432347502 -0400 +++ gcc-4.4-20090223/gcc/testsuite/gcc.dg/pr33763.c 2009-03-14 20:12:48.432347502 -0400 @@ -0,0 +1,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); +} diff -p -up gcc-4.4-20090223/gcc/tree-inline.c.pr33763 gcc-4.4-20090223/gcc/tree-inline.c --- gcc-4.4-20090223/gcc/tree-inline.c.pr33763 2009-02-22 18:39:33.000000000 -0500 +++ gcc-4.4-20090223/gcc/tree-inline.c 2009-03-14 20:12:48.431354568 -0400 @@ -3157,6 +3157,12 @@ expand_call_inline (basic_block bb, gimp goto egress; if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) + /* For extern inline functions that get redefined we always + silently ignored alway_inline flag. Better behaviour would + be to be able to keep both bodies and use extern inline body + for inlining, but we can't do that because frontends overwrite + the body. */ + && !cg_edge->callee->local.redefined_extern_inline /* Avoid warnings during early inline pass. */ && cgraph_global_info_ready) {