------- Comment #30 from rguenth at gcc dot gnu dot org 2008-01-15 15:21
-------
I suggest to tag the DECL with TREE_NO_WARNING if -fno-default-inline is set
and
check this.
On the trunk the functions are inlined anyway, because we inline small
functions by default (and the functions are pure anyway). Also trunk
tests
if (!flag_inline_small_functions && !DECL_DECLARED_INLINE_P (decl))
{
if (reason)
*reason = N_("function not inline candidate");
return false;
that is, it uses DECL_DECLARED_INLINE_P (!) which is not affected by
-fno-default-inline.
Better testcase:
volatile int x;
struct Foo {
int a(int r) { return r & x; }
virtual int b(int r) { return r & x; }
static int c(int r) { return r & x; }
};
int bar(int r) {
Foo f; int k = 0;
k |= f.a(r); k |= f.b(r); k |= f.a(r);
return k;
}
which will on the trunk warn with -fno-inline only.
With the proposed approach we'd improve this to
./cc1plus -quiet -Winline t.ii -O -fno-default-inline -fno-inline
t.ii: In constructor 'Foo::Foo()':
t.ii:2: warning: function 'Foo::Foo() throw ()' can never be inlined because it
is suppressed using -fno-inline
t.ii: In function 'int bar(int)':
t.ii:2: warning: inlining failed in call to 'Foo::Foo() throw ()': function not
inlinable
t.ii:9: warning: called from here
that is, the compiler-generated methods are still marked inline and are not
affected by -fno-default-inline.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org, hubicka at gcc dot gnu
| |dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18071