From df2c7ecb54999c7d09b7d3fda550f66c8e46ccde Mon Sep 17 00:00:00 2001 From: gdr Date: Sat, 27 Sep 2003 16:44:05 +0000 Subject: * name-lookup.h (get_global_value_if_present): New function. (is_typename_at_global_scope): Likewise. * except.c (do_begin_catch): Use get_global_value_if_present. (do_end_catch): Likewise. (do_allocate_exception): Likewise. (do_free_exception): Likewise. (build_throw): Likewise. * parser.c (cp_parser_member_declaration): Likewise. * rtti.c (throw_bad_cast): Likewise. (throw_bad_typeid): Likewise. * decl.c (check_tag_decl): Use is_typename_at_global_scope. (grokdeclarator): Likewise. * cp-tree.h (global_namespace): Move to name-lookup.h * call.c (call_builtin_trap): Tidy. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71858 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/name-lookup.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gcc/cp/name-lookup.h') diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 923f4806adc..04c6161dbc4 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -97,6 +97,9 @@ extern cxx_binding *cxx_binding_make (tree, tree); extern void cxx_binding_free (cxx_binding *); extern bool supplement_binding (cxx_binding *, tree); +/* The tree node representing the global scope. */ +extern GTY(()) tree global_namespace; + /* True if SCOPE designates the global scope binding contour. */ #define global_scope_p(SCOPE) \ ((SCOPE) == NAMESPACE_LEVEL (global_namespace)) @@ -107,4 +110,28 @@ extern cxx_binding *binding_for_name (cxx_scope *, tree); extern tree namespace_binding (tree, tree); extern void set_namespace_binding (tree, tree, tree); + +/* Set *DECL to the (non-hidden) declaration for ID at global scope, + if present and return true; otherwise return false. */ + +static inline bool +get_global_value_if_present (tree id, tree *decl) +{ + tree global_value = namespace_binding (id, global_namespace); + + if (global_value) + *decl = global_value; + return global_value != NULL; +} + +/* True is the binding of IDENTIFIER at global scope names a type. */ + +static inline bool +is_typename_at_global_scope (tree id) +{ + tree global_value = namespace_binding (id, global_namespace); + + return global_value && TREE_CODE (global_value) == TYPE_DECL; +} + #endif /* GCC_CP_NAME_LOOKUP_H */ -- cgit v1.2.1