From 1a10290c1cb47d0e1308e35e56087c53344daaae Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Tue, 17 Aug 2004 20:56:25 +0000 Subject: [PATCH] re PR c++/15871 (g++ does not honour -fkeep-inline-functions) PR c++/15871 * semantics.c (expand_or_defer_fn): Honor -fkeep-inline-functions. PR c++/15871 * doc/invoke.texi (-fkeep-inline-functions): Update documentation. PR c++/15871 * g++.dg/opt/inline8.C: New test. From-SVN: r86144 --- gcc/ChangeLog | 5 +++++ gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 8 +++++++- gcc/doc/invoke.texi | 9 +++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/opt/inline8.C | 5 +++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/inline8.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8525cace914..407ee87b94d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-08-17 Mark Mitchell + + PR c++/15871 + * doc/invoke.texi (-fkeep-inline-functions): Update documentation. + 2004-08-17 Robert Bowdidge * config/rs6000/x-darwin: Add -mdynamic-no-pic to gcc build flags. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7ccf881bd54..92e5751840c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2004-08-17 Mark Mitchell + PR c++/15871 + * semantics.c (expand_or_defer_fn): Honor -fkeep-inline-functions. + PR c++/16965 * cp-tree.h (qualified_name_lookup_error): Add parameter. * name-lookup.c (do_class_using_decl): Restrict set of entities diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f21c926d1dd..302d00ecc77 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2959,7 +2959,7 @@ expand_or_defer_fn (tree fn) /* We make a decision about linkage for these functions at the end of the compilation. Until that point, we do not want the back end to output them -- but we do want it to see the bodies of - these fucntions so that it can inline them as appropriate. */ + these functions so that it can inline them as appropriate. */ if (DECL_DECLARED_INLINE_P (fn) || DECL_IMPLICIT_INSTANTIATION (fn)) { if (!at_eof) @@ -2970,6 +2970,12 @@ expand_or_defer_fn (tree fn) } else import_export_decl (fn); + + /* If the user wants us to keep all inline functions, then mark + this function as needed so that finish_file will make sure to + output it later. */ + if (flag_keep_inline_functions && DECL_DECLARED_INLINE_P (fn)) + mark_needed (fn); } /* There's no reason to do any of the work here if we're only doing diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 4eb1498ddca..0cf590c2319 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4055,10 +4055,11 @@ release to an another. @item -fkeep-inline-functions @opindex fkeep-inline-functions -Even if all calls to a given function are integrated, and the function -is declared @code{static}, nevertheless output a separate run-time -callable version of the function. This switch does not affect -@code{extern inline} functions. +In C, emit @code{static} functions that are declared @code{inline} +into the object file, even if the function has been inlined into all +of its callers. This switch does not affect functions using the +@code{extern inline} extension in GNU C. In C++, emit any and all +inline functions into the object file. @item -fkeep-static-consts @opindex fkeep-static-consts diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cd593ddcc72..621d0cf2969 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2004-08-17 Mark Mitchell + PR c++/15871 + * g++.dg/opt/inline8.C: New test. + PR c++/16965 * g++.dg/parse/error17.C: New test. diff --git a/gcc/testsuite/g++.dg/opt/inline8.C b/gcc/testsuite/g++.dg/opt/inline8.C new file mode 100644 index 00000000000..b2ca021b039 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/inline8.C @@ -0,0 +1,5 @@ +// PR c++/15871 +// { dg-options "-O2 -fkeep-inline-functions" } +// { dg-final { scan-assembler "foo" } } + +inline void foo(void) { } -- 2.30.2