Commit 7bbd0aab by Mike Stump Committed by Mike Stump

c-common.c (handle_cleanup_attribute): Use a lang hook for lookup_name.

	* c-common.c (handle_cleanup_attribute): Use a lang hook for lookup_name.
	* config/darwin-c.c (darwin_pragma_unused): Likewise.
	* c-decl.c (lookup_name_two) Remove.
	* c-tree.h (lookup_name_two): Remove.
	* c-objc-common.h (LANG_HOOKS_LOOKUP_NAME): Add.
	* langhooks-def.h (LANG_HOOKS_LOOKUP_NAME): Add.
	(LANG_HOOKS_DECLS): Add initializer for LANG_HOOKS_LOOKUP_NAME.
	* langhooks.h (lang_hooks_for_decls): Add lookup_name.

cp:
	* cp-objcp-common.h (LANG_HOOKS_LOOKUP_NAME): Add.
	* name-lookup.c (lookup_name_two): Remove.
	(lookup_name_one): Add.
	* name-lookup.h (lookup_name_two): Remove.
	(lookup_name_one): Add.

From-SVN: r107196
parent 186abafe
2005-11-18 Mike Stump <mrs@apple.com>
* c-common.c (handle_cleanup_attribute): Use a lang hook for lookup_name.
* config/darwin-c.c (darwin_pragma_unused): Likewise.
* c-decl.c (lookup_name_two) Remove.
* c-tree.h (lookup_name_two): Remove.
* c-objc-common.h (LANG_HOOKS_LOOKUP_NAME): Add.
* langhooks-def.h (LANG_HOOKS_LOOKUP_NAME): Add.
(LANG_HOOKS_DECLS): Add initializer for LANG_HOOKS_LOOKUP_NAME.
* langhooks.h (lang_hooks_for_decls): Add lookup_name.
2005-11-18 Richard Earnshaw <richard.earnshaw@arm.com> 2005-11-18 Richard Earnshaw <richard.earnshaw@arm.com>
PR target/24914 PR target/24914
......
...@@ -5464,7 +5464,7 @@ handle_cleanup_attribute (tree *node, tree name, tree args, ...@@ -5464,7 +5464,7 @@ handle_cleanup_attribute (tree *node, tree name, tree args,
*no_add_attrs = true; *no_add_attrs = true;
return NULL_TREE; return NULL_TREE;
} }
cleanup_decl = lookup_name_two (cleanup_id, 0); cleanup_decl = lang_hooks.decls.lookup_name (cleanup_id);
if (!cleanup_decl || TREE_CODE (cleanup_decl) != FUNCTION_DECL) if (!cleanup_decl || TREE_CODE (cleanup_decl) != FUNCTION_DECL)
{ {
error ("cleanup argument not a function"); error ("cleanup argument not a function");
......
...@@ -2671,15 +2671,6 @@ lookup_name (tree name) ...@@ -2671,15 +2671,6 @@ lookup_name (tree name)
return 0; return 0;
} }
/* Similar to `lookup_name' for the benefit of common code and the C++
front end. */
tree
lookup_name_two (tree name, int ARG_UNUSED (prefer_type))
{
return lookup_name (name);
}
/* Similar to `lookup_name' but look only at the indicated scope. */ /* Similar to `lookup_name' but look only at the indicated scope. */
static tree static tree
......
...@@ -127,6 +127,8 @@ extern void c_initialize_diagnostics (diagnostic_context *); ...@@ -127,6 +127,8 @@ extern void c_initialize_diagnostics (diagnostic_context *);
#undef LANG_HOOKS_GETDECLS #undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS lhd_return_null_tree_v #define LANG_HOOKS_GETDECLS lhd_return_null_tree_v
#undef LANG_HOOKS_LOOKUP_NAME
#define LANG_HOOKS_LOOKUP_NAME lookup_name
#undef LANG_HOOKS_WRITE_GLOBALS #undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations #define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations
......
...@@ -455,7 +455,6 @@ extern tree grokparm (const struct c_parm *); ...@@ -455,7 +455,6 @@ extern tree grokparm (const struct c_parm *);
extern tree implicitly_declare (tree); extern tree implicitly_declare (tree);
extern void keep_next_level (void); extern void keep_next_level (void);
extern tree lookup_name (tree); extern tree lookup_name (tree);
extern tree lookup_name_two (tree, int);
extern void pending_xref_error (void); extern void pending_xref_error (void);
extern void c_push_function_context (struct function *); extern void c_push_function_context (struct function *);
extern void c_pop_function_context (struct function *); extern void c_pop_function_context (struct function *);
......
...@@ -33,6 +33,7 @@ Boston, MA 02110-1301, USA. */ ...@@ -33,6 +33,7 @@ Boston, MA 02110-1301, USA. */
#include "tm_p.h" #include "tm_p.h"
#include "cppdefault.h" #include "cppdefault.h"
#include "prefix.h" #include "prefix.h"
#include "langhooks.h"
/* Pragmas. */ /* Pragmas. */
...@@ -141,7 +142,7 @@ darwin_pragma_unused (cpp_reader *pfile ATTRIBUTE_UNUSED) ...@@ -141,7 +142,7 @@ darwin_pragma_unused (cpp_reader *pfile ATTRIBUTE_UNUSED)
tok = c_lex (&decl); tok = c_lex (&decl);
if (tok == CPP_NAME && decl) if (tok == CPP_NAME && decl)
{ {
tree local = lookup_name_two (decl, 0); tree local = lang_hooks.decls.lookup_name (decl);
if (local && (TREE_CODE (local) == PARM_DECL if (local && (TREE_CODE (local) == PARM_DECL
|| TREE_CODE (local) == VAR_DECL)) || TREE_CODE (local) == VAR_DECL))
TREE_USED (local) = 1; TREE_USED (local) = 1;
......
2005-11-18 Mike Stump <mrs@apple.com>
* cp-objcp-common.h (LANG_HOOKS_LOOKUP_NAME): Add.
* name-lookup.c (lookup_name_two): Remove.
(lookup_name_one): Add.
* name-lookup.h (lookup_name_two): Remove.
(lookup_name_one): Add.
2005-11-15 Jason Merrill <jason@redhat.com> 2005-11-15 Jason Merrill <jason@redhat.com>
PR c++/24580 PR c++/24580
......
...@@ -151,5 +151,7 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, ...@@ -151,5 +151,7 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
#define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
#undef LANG_HOOKS_GIMPLIFY_EXPR #undef LANG_HOOKS_GIMPLIFY_EXPR
#define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr #define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr
#undef LANG_HOOKS_LOOKUP_NAME
#define LANG_HOOKS_LOOKUP_NAME lookup_name_one
#endif /* GCC_CP_OBJCP_COMMON */ #endif /* GCC_CP_OBJCP_COMMON */
...@@ -4003,9 +4003,9 @@ lookup_name (tree name, int prefer_type) ...@@ -4003,9 +4003,9 @@ lookup_name (tree name, int prefer_type)
/* Similar to `lookup_name' for the benefit of common code. */ /* Similar to `lookup_name' for the benefit of common code. */
tree tree
lookup_name_two (tree name, int prefer_type) lookup_name_one (tree name)
{ {
return lookup_name (name, prefer_type); return lookup_name (name, 0);
} }
/* Look up NAME for type used in elaborated name specifier in /* Look up NAME for type used in elaborated name specifier in
......
...@@ -313,7 +313,7 @@ extern void pushlevel_class (void); ...@@ -313,7 +313,7 @@ extern void pushlevel_class (void);
extern void poplevel_class (void); extern void poplevel_class (void);
extern tree pushdecl_with_scope (tree, cxx_scope *, bool); extern tree pushdecl_with_scope (tree, cxx_scope *, bool);
extern tree lookup_name (tree, int); extern tree lookup_name (tree, int);
extern tree lookup_name_two (tree, int); extern tree lookup_name_one (tree);
extern tree lookup_name_real (tree, int, int, bool, int, int); extern tree lookup_name_real (tree, int, int, bool, int, int);
extern tree lookup_type_scope (tree, tag_scope); extern tree lookup_type_scope (tree, tag_scope);
extern tree namespace_binding (tree, tree); extern tree namespace_binding (tree, tree);
......
...@@ -234,6 +234,7 @@ extern tree lhd_make_node (enum tree_code); ...@@ -234,6 +234,7 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_INSERT_BLOCK insert_block #define LANG_HOOKS_INSERT_BLOCK insert_block
#define LANG_HOOKS_PUSHDECL pushdecl #define LANG_HOOKS_PUSHDECL pushdecl
#define LANG_HOOKS_GETDECLS getdecls #define LANG_HOOKS_GETDECLS getdecls
#define LANG_HOOKS_LOOKUP_NAME lhd_return_null_tree
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
#define LANG_HOOKS_WRITE_GLOBALS write_global_declarations #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL
...@@ -245,6 +246,7 @@ extern tree lhd_make_node (enum tree_code); ...@@ -245,6 +246,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_INSERT_BLOCK, \ LANG_HOOKS_INSERT_BLOCK, \
LANG_HOOKS_PUSHDECL, \ LANG_HOOKS_PUSHDECL, \
LANG_HOOKS_GETDECLS, \ LANG_HOOKS_GETDECLS, \
LANG_HOOKS_LOOKUP_NAME, \
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS, \ LANG_HOOKS_WRITE_GLOBALS, \
LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \ LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \
......
...@@ -170,6 +170,12 @@ struct lang_hooks_for_decls ...@@ -170,6 +170,12 @@ struct lang_hooks_for_decls
/* Returns the chain of decls so far in the current scope level. */ /* Returns the chain of decls so far in the current scope level. */
tree (*getdecls) (void); tree (*getdecls) (void);
/* Look up NAME in the current scope and its superiors
in the namespace of variables, functions and typedefs.
Return a ..._DECL node of some kind representing its definition,
or return 0 if it is undefined. */
tree (*lookup_name) (tree);
/* Returns true when we should warn for an unused global DECL. /* Returns true when we should warn for an unused global DECL.
We will already have checked that it has static binding. */ We will already have checked that it has static binding. */
bool (*warn_unused_global) (tree); bool (*warn_unused_global) (tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment