> > As I wrote in another mail, the only difference I'm aware of is > > the DECL_NO_INLINE_WARNING_P flag, which is set on bar and not on bar2 > > in this case. That flag is used just for -Winline warning. > > > > int baz (void *); > > > > struct S { > > int foo (int n) { return baz (__builtin_alloca (n)); } > > inline int bar (int n) { return baz (__builtin_alloca (n)); } > > }; > > > > int > > baz (int n) > > { > > return S{}.foo (n) + S{}.bar (n); > > } > > > > We do warn with -O2 -Winline about not inlining bar, but not foo. > > This was changed in PR18071. > > Which was about -fno-default-inline which was removed in 2013. So I > think it's a bug that -Winline still treats S::foo and S::bar > differently.
Sorry, I am getting old and this was recollection from long time ago. In 2001-2003 when C++ triggered kind of "inlining crisis" due to the fact that C++ makes people to write a lot of code into class/template definitions which is not really intended for inlining, but has inline hint on them. To prevent GCC from exploding on templatized code we had to weaken handling of DECL_DECLARED_INLINE which made C developers unhappy since they expect it to be strong hint. For this reason we introduced DECL_INLINE and DECL_DECLARED_INLINE to distinguish implicit inlines from explicit inlines and also added always_inline. I rewrote inliner heuristics in 2003 and dropped the difference in 2008 :)) Honza