This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR c++/10888
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 20 Jun 2003 12:33:27 -0700
- Subject: C++ PATCH: PR c++/10888
- Reply-to: mark at codesourcery dot com
This patch fixes PR 10888, which points out that -Winline (now that it
works at all) warns about failures to inline functions declared in
system headers.
I made it shut up about functions declared in system headers, which
might make it somewhat more useful. If you really want to know
whether a function declared in a system header gets inlined (which you
might, after all), you'll just have to read the .s file.
(I think we should just get rid of -Winline; if you want to know what
optimization decisions the compiler made when running your code you
want much more detailed output, and -Winline is inherently incredibly
fragile. Tiny changes in the input program can result in substantial
differences in the output.)
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-06-20 Mark Mitchell <mark@codesourcery.com>
PR c++/10888
* tree-inline.c (expand_call_inline): Do not warn about failing to
inline functions declared in system headers.
* doc/invoke.texi (-Winline): Expand on documentation.
2003-06-20 Mark Mitchell <mark@codesourcery.com>
PR c++/10888
* g++.dg/warn/Winline-2.C: New test.
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.38.2.9
diff -c -5 -p -r1.38.2.9 tree-inline.c
*** tree-inline.c 17 Jun 2003 23:01:58 -0000 1.38.2.9
--- tree-inline.c 20 Jun 2003 19:20:23 -0000
*************** expand_call_inline (tp, walk_subtrees, d
*** 1169,1179 ****
/* Don't try to inline functions that are not well-suited to
inlining. */
if (!inlinable_function_p (fn, id))
{
! if (warn_inline && DECL_INLINE (fn) && !DID_INLINE_FUNC (fn))
{
warning_with_decl (fn, "inlining failed in call to `%s'");
warning ("called from here");
}
return NULL_TREE;
--- 1169,1180 ----
/* Don't try to inline functions that are not well-suited to
inlining. */
if (!inlinable_function_p (fn, id))
{
! if (warn_inline && DECL_INLINE (fn) && !DID_INLINE_FUNC (fn)
! && !DECL_IN_SYSTEM_HEADER (fn))
{
warning_with_decl (fn, "inlining failed in call to `%s'");
warning ("called from here");
}
return NULL_TREE;
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.209.2.30
diff -c -5 -p -r1.209.2.30 invoke.texi
*** doc/invoke.texi 17 Jun 2003 17:03:35 -0000 1.209.2.30
--- doc/invoke.texi 20 Jun 2003 19:20:56 -0000
*************** because the program does work. Another
*** 2760,2769 ****
--- 2760,2778 ----
code is to provide behavior which is selectable at compile-time.
@item -Winline
@opindex Winline
Warn if a function can not be inlined and it was declared as inline.
+ Even with this option, the compiler will not warn about failures to
+ inline functions declared in system headers.
+
+ The compiler uses a variety of heuristics to determine whether or not
+ to inline a function. For example, the compiler takes into account
+ the size of the function being inlined and the the amount of inlining
+ that has already been done in the current function. Therefore,
+ seemingly insignificant changes in the source program can cause the
+ warnings produced by @option{-Winline} to appear or disappear.
@item -Wlong-long
@opindex Wlong-long
@opindex Wno-long-long
Warn if @samp{long long} type is used. This is default. To inhibit
Index: testsuite/g++.dg/warn/Winline-2.C
===================================================================
RCS file: testsuite/g++.dg/warn/Winline-2.C
diff -N testsuite/g++.dg/warn/Winline-2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Winline-2.C 20 Jun 2003 19:20:57 -0000
***************
*** 0 ****
--- 1,11 ----
+ // { dg-options "-Winline -O" }
+
+ #include <vector>
+
+ using namespace std;
+
+ int main(void)
+ {
+ vector<int> v(10);
+ }
+