summaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-26 18:20:14 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-26 18:20:14 +0000
commit2df457620208e53ee3febc057463e5b20fc7d085 (patch)
tree3b3f68cfdf157cf39c688a14d74c859083f1a06c /gcc/cp/decl2.c
parentf358d8ebf53c62cf4d84d2d2e2c86f43396d18c6 (diff)
downloadgcc-2df457620208e53ee3febc057463e5b20fc7d085.tar.gz
cp:
PR c++/4803 * decl2.c (mark_used): Defer inline functions. (finish_file): Merge deferred_fns loops. Check all used inline functions have a definition. * method.c (make_thunk): Thunks are not inline. testsuite: * g++.dg/warn/inline1.C: New test. * g++.old-deja/g++.brendan/crash64.C: Remove spurious inlines. * g++.old-deja/g++.jason/synth10.C: Likewise. * g++.old-deja/g++.mike/net31.C: Likewise. * g++.old-deja/g++.mike/p8786.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60521 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 3d717e8475b..1607e379090 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2791,12 +2791,13 @@ finish_file ()
reconsider = 1;
}
- /* Go through the various inline functions, and see if any need
- synthesizing. */
for (i = 0; i < deferred_fns_used; ++i)
{
tree decl = VARRAY_TREE (deferred_fns, i);
+
import_export_decl (decl);
+
+ /* Does it need synthesizing? */
if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
&& TREE_USED (decl)
&& (! DECL_REALLY_EXTERN (decl) || DECL_INLINE (decl)))
@@ -2811,30 +2812,21 @@ finish_file ()
pop_from_top_level ();
reconsider = 1;
}
- }
- /* We lie to the back-end, pretending that some functions are
- not defined when they really are. This keeps these functions
- from being put out unnecessarily. But, we must stop lying
- when the functions are referenced, or if they are not comdat
- since they need to be put out now.
- This is done in a separate for cycle, because if some deferred
- function is contained in another deferred function later in
- deferred_fns varray, rest_of_compilation would skip this
- function and we really cannot expand the same function twice. */
- for (i = 0; i < deferred_fns_used; ++i)
- {
- tree decl = VARRAY_TREE (deferred_fns, i);
-
+ /* We lie to the back-end, pretending that some functions
+ are not defined when they really are. This keeps these
+ functions from being put out unnecessarily. But, we must
+ stop lying when the functions are referenced, or if they
+ are not comdat since they need to be put out now. This
+ is done in a separate for cycle, because if some deferred
+ function is contained in another deferred function later
+ in deferred_fns varray, rest_of_compilation would skip
+ this function and we really cannot expand the same
+ function twice. */
if (DECL_NOT_REALLY_EXTERN (decl)
&& DECL_INITIAL (decl)
&& DECL_NEEDED_P (decl))
DECL_EXTERNAL (decl) = 0;
- }
-
- for (i = 0; i < deferred_fns_used; ++i)
- {
- tree decl = VARRAY_TREE (deferred_fns, i);
/* If we're going to need to write this function out, and
there's already a body for it, create RTL for it now.
@@ -2890,6 +2882,16 @@ finish_file ()
}
while (reconsider);
+ /* All used inline functions must have a definition at this point. */
+ for (i = 0; i < deferred_fns_used; ++i)
+ {
+ tree decl = VARRAY_TREE (deferred_fns, i);
+
+ if (TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
+ && !(TREE_ASM_WRITTEN (decl) || DECL_SAVED_TREE (decl)))
+ cp_warning_at ("inline function `%D' used but never defined", decl);
+ }
+
/* We give C linkage to static constructors and destructors. */
push_lang_context (lang_name_c);
@@ -4665,6 +4667,12 @@ mark_used (decl)
TREE_USED (decl) = 1;
if (processing_template_decl)
return;
+
+ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)
+ && !TREE_ASM_WRITTEN (decl))
+ /* Remember it, so we can check it was defined. */
+ defer_fn (decl);
+
if (!skip_evaluation)
assemble_external (decl);