This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
:ADDPATCH middle-end/18071:
Winline complains about methods not inlined even when using -fno-default-inline. We have two bits in our tree representation:
DECL_DECLARED_INLINE_P : Nonzero in a FUNCTION_DECL means that this function was declared inline, such as via the `inline' keyword in C/C++. This flag controls the linkage semantics of 'inline'; whether or not the function is inlined is controlled by DECL_INLINE.
DECL_INLINE : Nonzero in a FUNCTION_DECL means this function can be substituted where it is called.
Currently, with -fdefault-inline (the default) we set both to 1 for methods (even if the methods have no explicit "inline" keyword. With -fno-default-inline we set only DECL_DECLARED_INLINE_P.
The definition of Winline is "Warn if a function can not be inlined and it was declared as inline." It seems that we should only warn if DECL_DECLARED_INLINE_P and don't care about the value of DECL_INLINE.
So, this patch does two things:
* It makes sure we emit the warning only if DECL_DECLARED_INLINE_P is true without taking into account the value of DECL_INLINE.
* It does not set DECL_DECLARED_INLINE_P for methods unless they are declared inline or -fdefault-inline is true (which is the default).
I am not sure whether the latter breaks the current description of -fno-default-inline: "Note that these functions will have linkage like inline functions; they just won't be inlined by default".
I also would like to test whether the methods were inlined by default and when using the keyword inline and -fno-default-inline. Unfortunately, I am not sure how to do this (looking in the testsuite didn't give any ideas). Also, I am not sure how to force the warnings to appear, so we can check that they are emitted when they should.
So suggestions and comments are very welcome.
Bootstrapped and regression tested with --enable-languages=all for revision 120770 on i686-pc-linux-gnu.
OK for mainline?
Manuel.
2007-01-16 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/18071 * c-objc-common.c (c_cannot_inline_tree_fn): Internal notes like DECL_INLINE should not affect -Winline. * tree-inline.c (inlinable_function_p): Likewise.
cp/ * decl.c (start_method): Don't set DECL_DECLARED_INLINE_P if -fno-default-inline.
testsuite/ * g++.dg/warn/Winline-5.C: New * g++.dg/warn/Winline-6.C: New * g++.dg/warn/Winline-7.C: New
Attachment:
winline.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |