c-decl.c (finish_decl): Apply pending #pragma weak regardless of scope.

* 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
This commit is contained in:
Joseph Myers 2005-04-06 18:17:38 +01:00 committed by Joseph Myers
parent c634366a35
commit 3693d46c97
7 changed files with 50 additions and 4 deletions

View 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,

View 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

View 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

View 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)

View 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,

View File

@ -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;
}

View File

@ -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;
}