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
This commit is contained in:
Mike Stump 2005-11-18 23:40:29 +00:00 committed by Mike Stump
parent 186abafe49
commit 7bbd0aab4c
12 changed files with 37 additions and 15 deletions

View File

@ -1,3 +1,14 @@
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>
PR target/24914

View File

@ -5464,7 +5464,7 @@ handle_cleanup_attribute (tree *node, tree name, tree args,
*no_add_attrs = true;
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)
{
error ("cleanup argument not a function");

View File

@ -2671,15 +2671,6 @@ lookup_name (tree name)
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. */
static tree

View File

@ -127,6 +127,8 @@ extern void c_initialize_diagnostics (diagnostic_context *);
#undef LANG_HOOKS_GETDECLS
#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
#define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations

View File

@ -455,7 +455,6 @@ extern tree grokparm (const struct c_parm *);
extern tree implicitly_declare (tree);
extern void keep_next_level (void);
extern tree lookup_name (tree);
extern tree lookup_name_two (tree, int);
extern void pending_xref_error (void);
extern void c_push_function_context (struct function *);
extern void c_pop_function_context (struct function *);

View File

@ -33,6 +33,7 @@ Boston, MA 02110-1301, USA. */
#include "tm_p.h"
#include "cppdefault.h"
#include "prefix.h"
#include "langhooks.h"
/* Pragmas. */
@ -141,7 +142,7 @@ darwin_pragma_unused (cpp_reader *pfile ATTRIBUTE_UNUSED)
tok = c_lex (&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
|| TREE_CODE (local) == VAR_DECL))
TREE_USED (local) = 1;

View File

@ -1,3 +1,11 @@
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>
PR c++/24580

View File

@ -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
#undef LANG_HOOKS_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 */

View File

@ -4003,9 +4003,9 @@ lookup_name (tree name, int prefer_type)
/* Similar to `lookup_name' for the benefit of common code. */
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

View File

@ -313,7 +313,7 @@ extern void pushlevel_class (void);
extern void poplevel_class (void);
extern tree pushdecl_with_scope (tree, cxx_scope *, bool);
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_type_scope (tree, tag_scope);
extern tree namespace_binding (tree, tree);

View File

@ -234,6 +234,7 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_INSERT_BLOCK insert_block
#define LANG_HOOKS_PUSHDECL pushdecl
#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_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL
@ -245,6 +246,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_INSERT_BLOCK, \
LANG_HOOKS_PUSHDECL, \
LANG_HOOKS_GETDECLS, \
LANG_HOOKS_LOOKUP_NAME, \
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS, \
LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \

View File

@ -170,6 +170,12 @@ struct lang_hooks_for_decls
/* Returns the chain of decls so far in the current scope level. */
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.
We will already have checked that it has static binding. */
bool (*warn_unused_global) (tree);