diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-15 07:11:14 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-15 07:11:14 +0000 |
commit | 5626f4cd4a46a52ef1e4737fce9b343d6873bafd (patch) | |
tree | a4832f691fe7468c7db7811469b930a129616f84 /gcc/c-decl.c | |
parent | 60e8331cd1525190672dc76f94a32786e30cdad0 (diff) | |
download | gcc-5626f4cd4a46a52ef1e4737fce9b343d6873bafd.tar.gz |
* c-decl.c: Include c-pragma.h.
(start_decl, start_function): Invoke maybe_apply_pragma_weak.
(finish_function): Tidy.
* c-pragma.c: Include c-common.h.
(pending_weaks, apply_pragma_weak, maybe_apply_pragma_weak): New.
(handle_pragma_weak): Use them.
(init_pragma): Register pending_weaks.
* c-pragma.h (maybe_apply_pragma_weak): Declare.
* print-tree.c (print_node): Print DECL_WEAK.
* varasm.c (mark_weak_decls): Remove.
(remove_from_pending_weak_list): Remove.
(add_weak): Remove.
(asm_emit_uninitialised): Call globalize_decl for weak commons.
(weak_decls): Make a tree_list.
(declare_weak): Cons weak_decls directly.
(globalize_decl): Remove weak_decls elements directly.
(weak_finish): Simplify weak_decls walk. Don't weaken unused
symbols. Don't pretend to handle aliases.
(init_varasm_once): Update weak_decls registry.
* Makefile.in: Update dependencies.
* cp/decl.c: Include c-pragma.h.
(start_decl, start_function): Invoke maybe_apply_pragma_weak.
* cp/Make-lang.in: Update dependencies.
* gcc.dg/weak-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50797 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index d15f47e4baa..9242b03b3f9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -46,6 +46,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "debug.h" #include "timevar.h" #include "c-common.h" +#include "c-pragma.h" /* In grokdeclarator, distinguish syntactic contexts of declarators. */ enum decl_context @@ -3403,6 +3404,10 @@ start_decl (declarator, declspecs, initialized, attributes) /* Set attributes here so if duplicate decl, will have proper attributes. */ decl_attributes (&decl, attributes, 0); + /* If #pragma weak was used, mark the decl weak now. */ + if (current_binding_level == global_binding_level) + maybe_apply_pragma_weak (decl); + if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) && DECL_UNINLINABLE (decl) @@ -6042,6 +6047,10 @@ start_function (declspecs, declarator, attributes) decl_attributes (&decl1, attributes, 0); + /* If #pragma weak was used, mark the decl weak now. */ + if (current_binding_level == global_binding_level) + maybe_apply_pragma_weak (decl1); + if (DECL_DECLARED_INLINE_P (decl1) && DECL_UNINLINABLE (decl1) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1))) @@ -6691,9 +6700,11 @@ finish_function (nested) { tree fndecl = current_function_decl; -/* TREE_READONLY (fndecl) = 1; - This caused &foo to be of type ptr-to-const-function - which then got a warning when stored in a ptr-to-function variable. */ +#if 0 + /* This caused &foo to be of type ptr-to-const-function which then + got a warning when stored in a ptr-to-function variable. */ + TREE_READONLY (fndecl) = 1; +#endif poplevel (1, 0, 1); BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; @@ -6755,6 +6766,7 @@ finish_function (nested) { /* Generate RTL for the body of this function. */ c_expand_body (fndecl, nested, 1); + /* Let the error reporting routines know that we're outside a function. For a nested function, this value is used in pop_c_function_context and then reset via pop_function_context. */ |