summaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-15 22:50:18 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-15 22:50:18 +0000
commite9e7df9cb45f0525878047454c2208241cefed3e (patch)
treec19ee228e68d4f368a2d2afdfe04d9e838523ffc /gcc/cp/decl2.c
parent9e0bf4eb787586b645e0e6fc2dcabfdc6315086a (diff)
downloadgcc-e9e7df9cb45f0525878047454c2208241cefed3e.tar.gz
* decl2.c (decl_needed_p): When not optimizing, do not consider external
decls as needed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 07bdd92de93..b2123f2decb 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1996,19 +1996,30 @@ decl_needed_p (tree decl)
COMDAT until that point. */
gcc_assert (at_eof);
- /* All entities with external linkage that are not COMDAT should be
+ /* All entities with external linkage that are not COMDAT/EXTERN should be
emitted; they may be referred to from other object files. */
- if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
+ if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_REALLY_EXTERN (decl))
return true;
- /* If this entity was used, let the back end see it; it will decide
- whether or not to emit it into the object file. */
- if (TREE_USED (decl))
- return true;
/* Functions marked "dllexport" must be emitted so that they are
visible to other DLLs. */
if (flag_keep_inline_dllexport
&& lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))
return true;
+
+ /* When not optimizing, do not bother to produce definitions for extern
+ symbols. */
+ if (DECL_REALLY_EXTERN (decl)
+ && ((TREE_CODE (decl) != FUNCTION_DECL
+ && !optimize)
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && !opt_for_fn (decl, optimize)))
+ && !lookup_attribute ("always_inline", decl))
+ return false;
+
+ /* If this entity was used, let the back end see it; it will decide
+ whether or not to emit it into the object file. */
+ if (TREE_USED (decl))
+ return true;
/* Virtual functions might be needed for devirtualization. */
if (flag_devirtualize
&& TREE_CODE (decl) == FUNCTION_DECL