varasm.c (default_use_anchors_for_symbol_p): Use decl_replaceable_p.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 16 May 2013 10:29:42 +0000 (10:29 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 16 May 2013 10:29:42 +0000 (10:29 +0000)
gcc/
* varasm.c (default_use_anchors_for_symbol_p): Use decl_replaceable_p.

gcc/testsuite/
* gcc.dg/visibility-21.c: New.

From-SVN: r198965

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/visibility-21.c [new file with mode: 0644]
gcc/varasm.c

index 3a0929c..d6f6e5a 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-16  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * varasm.c (default_use_anchors_for_symbol_p): Use decl_replaceable_p.
+
 2013-05-16  Marc Glisse  <marc.glisse@inria.fr>
 
        PR middle-end/57286
index 6ec937c..7bacbb5 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-16  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * gcc.dg/visibility-21.c: New.
+
 2013-05-16  Marc Glisse  <marc.glisse@inria.fr>
 
        PR middle-end/57286
diff --git a/gcc/testsuite/gcc.dg/visibility-21.c b/gcc/testsuite/gcc.dg/visibility-21.c
new file mode 100644 (file)
index 0000000..264204e
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test visibility attribute on function definition. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsection-anchors" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-weak "" } */
+/* { dg-final { scan-assembler-not "ANCHOR" } } */
+
+int __attribute__((weak, visibility("hidden"))) weak_hidden[3];
+
+int *f_weak_hidden ()
+{
+  return weak_hidden;
+}
index 6fb49cf..5f62677 100644 (file)
@@ -6580,9 +6580,9 @@ default_use_anchors_for_symbol_p (const_rtx symbol)
   decl = SYMBOL_REF_DECL (symbol);
   if (decl && DECL_P (decl))
     {
-      /* Don't use section anchors for decls that might be defined by
-        other modules.  */
-      if (!targetm.binds_local_p (decl))
+      /* Don't use section anchors for decls that might be defined or
+        usurped by other modules.  */
+      if (TREE_PUBLIC (decl) && !decl_binds_to_current_def_p (decl))
        return false;
 
       /* Don't use section anchors for decls that will be placed in a