decl.c (grokmethod): Only set DECL_COMDAT if TREE_PUBLIC is set.
authorJason Merrill <jason@redhat.com>
Wed, 15 Apr 2015 21:17:21 +0000 (17:17 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 15 Apr 2015 21:17:21 +0000 (17:17 -0400)
* 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.

From-SVN: r222134

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/method.c

index 519fc81f812d36253eb3b7b4536a25a441f8d4c8..b18c2fb311ef6432711796becff6d4ceabf78031 100644 (file)
@@ -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>
index c8323b0e9a49573f08646fb48ea1e3e29e4f67f6..05385702978857c9f5e54b6409a0314912b8fc94 100644 (file)
@@ -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;
 
index 5a58d3391c8634f2d4a8bae4575d7d6c0384b2f1..b2251d80555cf96e64cdbdf5e988e3d8fdeda5eb 100644 (file)
@@ -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.  */
index 33e2f3cb52fb34e2b17720f3db4bcc80e478a6cd..81f50e6e23f143a8cb06c71143bbc4bce00a18ec 100644 (file)
@@ -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));