summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-04-15 21:17:21 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-04-15 21:17:21 +0000
commit8b2942f7c961ee83bb0ff605129165ecdf6ac8f6 (patch)
treee7bcd12be7b16d2c07af9220c8a405f902d4552d
parent0e3c4566533afa79313e2d2b57e587294003d7a8 (diff)
downloadgcc-8b2942f7c961ee83bb0ff605129165ecdf6ac8f6.tar.gz
* decl.c (grokmethod): Only set DECL_COMDAT if TREE_PUBLIC is set.
* method.c (implicitly_declare_fn): Likewise. * decl2.c (vague_linkage_p): Check TREE_PUBLIC first. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222134 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/decl2.c14
-rw-r--r--gcc/cp/method.c3
4 files changed, 17 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 519fc81f812..b18c2fb311e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2015-04-15 Jason Merrill <jason@redhat.com>
+ * decl.c (grokmethod): Only set DECL_COMDAT if TREE_PUBLIC is set.
+ * method.c (implicitly_declare_fn): Likewise.
+ * decl2.c (vague_linkage_p): Check TREE_PUBLIC first.
+
* decl2.c (determine_visibility): Use get_template_info.
2015-04-15 Jason Merrill <jason@redhat.com>
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c8323b0e9a4..05385702978 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14422,7 +14422,8 @@ grokmethod (cp_decl_specifier_seq *declspecs,
check_template_shadow (fndecl);
- DECL_COMDAT (fndecl) = 1;
+ if (TREE_PUBLIC (fndecl))
+ DECL_COMDAT (fndecl) = 1;
DECL_DECLARED_INLINE_P (fndecl) = 1;
DECL_NO_INLINE_WARNING_P (fndecl) = 1;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 5a58d3391c8..b2251d80555 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1861,15 +1861,19 @@ maybe_make_one_only (tree decl)
bool
vague_linkage_p (tree decl)
{
+ if (!TREE_PUBLIC (decl))
+ {
+ gcc_checking_assert (!DECL_COMDAT (decl));
+ return false;
+ }
/* Unfortunately, import_export_decl has not always been called
before the function is processed, so we cannot simply check
DECL_COMDAT. */
if (DECL_COMDAT (decl)
- || (((TREE_CODE (decl) == FUNCTION_DECL
- && DECL_DECLARED_INLINE_P (decl))
- || (DECL_LANG_SPECIFIC (decl)
- && DECL_TEMPLATE_INSTANTIATION (decl)))
- && TREE_PUBLIC (decl)))
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_DECLARED_INLINE_P (decl))
+ || (DECL_LANG_SPECIFIC (decl)
+ && DECL_TEMPLATE_INSTANTIATION (decl)))
return true;
else if (DECL_FUNCTION_SCOPE_P (decl))
/* A local static in an inline effectively has vague linkage. */
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 33e2f3cb52f..81f50e6e23f 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1925,8 +1925,9 @@ implicitly_declare_fn (special_function_kind kind, tree type,
DECL_EXTERNAL (fn) = true;
DECL_NOT_REALLY_EXTERN (fn) = 1;
DECL_DECLARED_INLINE_P (fn) = 1;
- DECL_COMDAT (fn) = 1;
set_linkage_according_to_type (type, fn);
+ if (TREE_PUBLIC (fn))
+ DECL_COMDAT (fn) = 1;
rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
gcc_assert (!TREE_USED (fn));