c-decl.c (finish_decl): Apply pending #pragma weak regardless of scope.
authorJoseph Myers <joseph@codesourcery.com>
Wed, 6 Apr 2005 17:17:38 +0000 (18:17 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 6 Apr 2005 17:17:38 +0000 (18:17 +0100)
* c-decl.c (finish_decl): Apply pending #pragma weak regardless of
scope.

cp:
* decl.c (start_decl): Apply pending #pragma weak regardless of
scope.

testsuite:
* gcc.dg/weak/weak-12.c, g++.dg/ext/weak2.C: New tests.

From-SVN: r97733

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/weak2.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/weak/weak-12.c [new file with mode: 0644]

index 7482326151e2a72b0f4077cf8f15b3517e499fb1..6d1882a583f86a143e3f3b1b9a97da25c074d7d0 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-06  Joseph S. Myers  <joseph@codesourcery.com>
+
+       * c-decl.c (finish_decl): Apply pending #pragma weak regardless of
+       scope.
+
 2005-04-06  Kazu Hirata  <kazu@cs.umass.edu>
 
        * cse.c, tree-flow-inline.h, tree-flow.h, tree-ssa-operands.c,
index 100f5a7ad460ea1d6a8a7da9000127f9aa9b8c51..d02d7429badd9ff63d8bc0af8fc1555ef07061e6 100644 (file)
@@ -3262,8 +3262,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
     }
 
   /* If #pragma weak was used, mark the decl weak now.  */
-  if (current_scope == file_scope)
-    maybe_apply_pragma_weak (decl);
+  maybe_apply_pragma_weak (decl);
 
   /* If this is a variable definition, determine its ELF visibility.  */
   if (TREE_CODE (decl) == VAR_DECL 
index 39e5a458e952774735e6ade026a805fa84321707..e0b452c6ae87112bd3fde3649897692b25ae89be 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-06  Joseph S. Myers  <joseph@codesourcery.com>
+
+       * decl.c (start_decl): Apply pending #pragma weak regardless of
+       scope.
+
 2005-04-06  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/20212
index 9618b4d3c2c781c63db8aee2272ace4b2235a9d8..acf8a85ada1c574a0916b0f5d12e947a3d43035c 100644 (file)
@@ -3654,8 +3654,7 @@ start_decl (const cp_declarator *declarator,
   cplus_decl_attributes (&decl, attributes, 0);
 
   /* If #pragma weak was used, mark the decl weak now.  */
-  if (global_scope_p (current_binding_level))
-    maybe_apply_pragma_weak (decl);
+  maybe_apply_pragma_weak (decl);
 
   if (TREE_CODE (decl) == FUNCTION_DECL
       && DECL_DECLARED_INLINE_P (decl)
index 5715b0ebead43de667d2b708b00db1673ee51064..962e7e0059d86d1a05b759998cce9d2e71277afe 100644 (file)
@@ -1,3 +1,7 @@
+2005-04-06  Joseph S. Myers  <joseph@codesourcery.com>
+
+       * gcc.dg/weak/weak-12.c, g++.dg/ext/weak2.C: New tests.
+
 2005-04-06  Joseph S. Myers  <joseph@codesourcery.com>
 
        * gcc.dg/i386-387-7.c, gcc.dg/i386-3dnowA-1.c,
diff --git a/gcc/testsuite/g++.dg/ext/weak2.C b/gcc/testsuite/g++.dg/ext/weak2.C
new file mode 100644 (file)
index 0000000..1bf2ddc
--- /dev/null
@@ -0,0 +1,17 @@
+// Test for #pragma weak with declaration not at file scope. 
+// { dg-do compile }
+// { dg-require-weak "" }
+// { dg-options "" }
+
+// { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?_Z3foov" } }
+
+#pragma weak _Z3foov
+
+int
+main (void)
+{
+  extern int foo (void);
+  if (&foo)
+    return foo ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/weak/weak-12.c b/gcc/testsuite/gcc.dg/weak/weak-12.c
new file mode 100644 (file)
index 0000000..72cc144
--- /dev/null
@@ -0,0 +1,17 @@
+/* Test for #pragma weak with declaration not at file scope.  */
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-options "" } */
+
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?foo" } } */
+
+#pragma weak foo
+
+int
+main (void)
+{
+  extern int foo (void);
+  if (&foo)
+    return foo ();
+  return 0;
+}