* cp-tree.h (IDENTIFIER_GLOBAL_VALUE): Use get_namespace_value.
(SET_IDENTIFIER_GLOBAL_VALUE): Use set_global_value.
(IDENTIFIER_NAMESPACE_VALUE): Delete.
* name-lookup.h (namespace_binding, set_namespace_binding):
Replace
with ...
(get_namespace_value, set_global_value): ... these.
(get_global_value_if_present, is_typename_at_global_scope):
Delete.
* decl.c (poplevel): Use get_namespace_value.
(grokdeclarator): Use IDENTIFIER_GLOBAL_VALUE.
* class.c (build_vtbl_initializer): Stash library decl in
static var. Use IDENTIFIER_GLOBAL_VALUE.
* except.c (do_get_exception_ptr, do_begin_catch, do_end_catch)
do_allocate_exception, do_free_exception, build_throw): Likewise.
* init.c (throw_bad_array_new_length): Likewise.
* rtti.c (throw_bad_cast, throw_bad_typeid): Likewise.
* name-lookup.c (arg_assoc_namespace, pushdecl_maybe_friend_1)
check_for_our_of_scope_variable, push_overloaded_decl_1): Use
get_namespace_value.
(set_namespace_binding_1): Rename to
(set_namespace_binding): ... here.
(set_global_value): New.
(lookup_name_innermost_nonclass_level_1, push_namespace): Use
get_namespace_value.
* pt.c (listify): Use get_namespace_value.
((--This line, and those below, will be ignored--
M cp/name-lookup.c
M cp/name-lookup.h
M cp/ChangeLog
M cp/except.c
M cp/class.c
M cp/pt.c
M cp/init.c
M cp/cp-tree.h
M cp/decl.c
M cp/rtti.c
From-SVN: r247654
2017-05-05 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.h (IDENTIFIER_GLOBAL_VALUE): Use get_namespace_value.
+ (SET_IDENTIFIER_GLOBAL_VALUE): Use set_global_value.
+ (IDENTIFIER_NAMESPACE_VALUE): Delete.
+ * name-lookup.h (namespace_binding, set_namespace_binding): Replace
+ with ...
+ (get_namespace_value, set_global_value): ... these.
+ (get_global_value_if_present, is_typename_at_global_scope): Delete.
+ * decl.c (poplevel): Use get_namespace_value.
+ (grokdeclarator): Use IDENTIFIER_GLOBAL_VALUE.
+ * class.c (build_vtbl_initializer): Stash library decl in
+ static var. Use IDENTIFIER_GLOBAL_VALUE.
+ * except.c (do_get_exception_ptr, do_begin_catch, do_end_catch,
+ do_allocate_exception, do_free_exception, build_throw): Likewise.
+ * init.c (throw_bad_array_new_length): Likewise.
+ * rtti.c (throw_bad_cast, throw_bad_typeid): Likewise.
+ * name-lookup.c (arg_assoc_namespace, pushdecl_maybe_friend_1,
+ check_for_our_of_scope_variable, push_overloaded_decl_1): Use
+ get_namespace_value.
+ (set_namespace_binding_1): Rename to
+ (set_namespace_binding): ... here.
+ (set_global_value): New.
+ (lookup_name_innermost_nonclass_level_1, push_namespace): Use
+ get_namespace_value.
+ * pt.c (listify): Use get_namespace_value.
+
* call.c (make_temporary_var_for_ref_to_temp): Push decl into
current scope.
* lex.c (unqualified_name_lookup_error): Likewise.
/* Likewise for deleted virtuals. */
else if (DECL_DELETED_FN (fn_original))
{
- fn = get_identifier ("__cxa_deleted_virtual");
- if (!get_global_value_if_present (fn, &fn))
- fn = push_library_fn (fn, (build_function_type_list
- (void_type_node, NULL_TREE)),
- NULL_TREE, ECF_NORETURN);
+ static tree fn;
+
+ if (!fn)
+ {
+ tree name = get_identifier ("__cxa_deleted_virtual");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
+ fn = push_library_fn
+ (name,
+ build_function_type_list (void_type_node, NULL_TREE),
+ NULL_TREE, ECF_NORETURN);
+ }
if (!TARGET_VTABLE_USES_DESCRIPTORS)
init = fold_convert (vfunc_ptr_type_node,
build_fold_addr_expr (fn));
typedef struct ptrmem_cst * ptrmem_cst_t;
#define IDENTIFIER_GLOBAL_VALUE(NODE) \
- namespace_binding ((NODE), global_namespace)
+ get_namespace_value (NULL_TREE, (NODE))
#define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \
- set_namespace_binding ((NODE), global_namespace, (VAL))
-#define IDENTIFIER_NAMESPACE_VALUE(NODE) \
- namespace_binding ((NODE), current_namespace)
-#define SET_IDENTIFIER_NAMESPACE_VALUE(NODE, VAL) \
- set_namespace_binding ((NODE), current_namespace, (VAL))
+ set_global_value ((NODE), (VAL))
#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
&& DECL_NAME (link))
{
tree name = DECL_NAME (link);
- cxx_binding *ob;
- tree ns_binding;
- ob = outer_binding (name,
- IDENTIFIER_BINDING (name),
- /*class_p=*/true);
+ cxx_binding *ob = outer_binding (name,
+ IDENTIFIER_BINDING (name),
+ /*class_p=*/true);
+ tree ns_binding = NULL_TREE;
if (!ob)
- ns_binding = IDENTIFIER_NAMESPACE_VALUE (name);
- else
- ns_binding = NULL_TREE;
+ ns_binding = get_namespace_value (current_namespace, name);
if (ob && ob->scope == current_binding_level->level_chain)
/* We have something like:
gcc_assert (flags == NO_SPECIAL);
flags = TYPENAME_FLAG;
sfk = sfk_conversion;
- if (is_typename_at_global_scope (dname))
+ tree glob = IDENTIFIER_GLOBAL_VALUE (dname);
+ if (glob && TREE_CODE (glob) == TYPE_DECL)
name = identifier_to_locale (IDENTIFIER_POINTER (dname));
else
name = "<invalid operator>";
static tree
do_get_exception_ptr (void)
{
- tree fn;
+ static tree fn;
- fn = get_identifier ("__cxa_get_exception_ptr");
- if (!get_global_value_if_present (fn, &fn))
+ if (!fn)
{
- /* Declare void* __cxa_get_exception_ptr (void *) throw(). */
- fn = declare_library_fn (fn, ptr_type_node, ptr_type_node,
- ECF_NOTHROW | ECF_PURE | ECF_LEAF | ECF_TM_PURE);
+ tree name = get_identifier ("__cxa_get_exception_ptr");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
+ /* Declare void* __cxa_get_exception_ptr (void *) throw(). */
+ fn = declare_library_fn
+ (name, ptr_type_node, ptr_type_node,
+ ECF_NOTHROW | ECF_PURE | ECF_LEAF | ECF_TM_PURE);
}
return cp_build_function_call_nary (fn, tf_warning_or_error,
static tree
do_begin_catch (void)
{
- tree fn;
+ static tree fn;
- fn = get_identifier ("__cxa_begin_catch");
- if (!get_global_value_if_present (fn, &fn))
+ if (!fn)
{
- /* Declare void* __cxa_begin_catch (void *) throw(). */
- fn = declare_library_fn (fn, ptr_type_node, ptr_type_node, ECF_NOTHROW);
-
- /* Create its transactional-memory equivalent. */
- if (flag_tm)
+ tree name = fn = get_identifier ("__cxa_begin_catch");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
{
- tree fn2 = get_identifier ("_ITM_cxa_begin_catch");
- if (!get_global_value_if_present (fn2, &fn2))
- fn2 = declare_library_fn (fn2, ptr_type_node,
- ptr_type_node, ECF_NOTHROW | ECF_TM_PURE);
- record_tm_replacement (fn, fn2);
+ /* Declare void* __cxa_begin_catch (void *) throw(). */
+ fn = declare_library_fn
+ (name, ptr_type_node, ptr_type_node, ECF_NOTHROW);
+
+ /* Create its transactional-memory equivalent. */
+ if (flag_tm)
+ {
+ tree itm_name = get_identifier ("_ITM_cxa_begin_catch");
+ tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ if (!itm_fn)
+ itm_fn = declare_library_fn
+ (itm_name, ptr_type_node, ptr_type_node,
+ ECF_NOTHROW | ECF_TM_PURE);
+ record_tm_replacement (fn, itm_fn);
+ }
}
}
static tree
do_end_catch (tree type)
{
- tree fn, cleanup;
+ static tree fn;
- fn = get_identifier ("__cxa_end_catch");
- if (!get_global_value_if_present (fn, &fn))
+ if (!fn)
{
- /* Declare void __cxa_end_catch ().
- This can throw if the destructor for the exception throws. */
- fn = push_void_library_fn (fn, void_list_node, 0);
-
- /* Create its transactional-memory equivalent. */
- if (flag_tm)
+ tree name = get_identifier ("__cxa_end_catch");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
{
- tree fn2 = get_identifier ("_ITM_cxa_end_catch");
- if (!get_global_value_if_present (fn2, &fn2))
- fn2 = push_void_library_fn (fn2, void_list_node, ECF_TM_PURE);
- record_tm_replacement (fn, fn2);
+ /* Declare void __cxa_end_catch ().
+ This can throw if the destructor for the exception throws. */
+ fn = push_void_library_fn (name, void_list_node, 0);
+
+ /* Create its transactional-memory equivalent. */
+ if (flag_tm)
+ {
+ tree itm_name = get_identifier ("_ITM_cxa_end_catch");
+ tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ if (!itm_fn)
+ itm_fn = push_void_library_fn
+ (itm_name, void_list_node, ECF_TM_PURE);
+ record_tm_replacement (fn, itm_fn);
+ }
}
}
- cleanup = cp_build_function_call_vec (fn, NULL, tf_warning_or_error);
+ tree cleanup = cp_build_function_call_vec (fn, NULL, tf_warning_or_error);
TREE_NOTHROW (cleanup) = dtor_nothrow (type);
return cleanup;
static tree
do_allocate_exception (tree type)
{
- tree fn;
+ static tree fn;
- fn = get_identifier ("__cxa_allocate_exception");
- if (!get_global_value_if_present (fn, &fn))
+ if (!fn)
{
- /* Declare void *__cxa_allocate_exception(size_t) throw(). */
- fn = declare_library_fn (fn, ptr_type_node, size_type_node,
- ECF_NOTHROW | ECF_MALLOC);
-
- if (flag_tm)
+ tree name = get_identifier ("__cxa_allocate_exception");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
{
- tree fn2 = get_identifier ("_ITM_cxa_allocate_exception");
- if (!get_global_value_if_present (fn2, &fn2))
- fn2 = declare_library_fn (fn2, ptr_type_node,
- size_type_node,
- ECF_NOTHROW | ECF_MALLOC | ECF_TM_PURE);
- record_tm_replacement (fn, fn2);
+ /* Declare void *__cxa_allocate_exception(size_t) throw(). */
+ fn = declare_library_fn (name, ptr_type_node, size_type_node,
+ ECF_NOTHROW | ECF_MALLOC);
+
+ if (flag_tm)
+ {
+ tree itm_name = get_identifier ("_ITM_cxa_allocate_exception");
+ tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ if (!itm_fn)
+ itm_fn = declare_library_fn
+ (itm_name, ptr_type_node, size_type_node,
+ ECF_NOTHROW | ECF_MALLOC | ECF_TM_PURE);
+ record_tm_replacement (fn, itm_fn);
+ }
}
}
static tree
do_free_exception (tree ptr)
{
- tree fn;
+ static tree fn;
- fn = get_identifier ("__cxa_free_exception");
- if (!get_global_value_if_present (fn, &fn))
+ if (!fn)
{
- /* Declare void __cxa_free_exception (void *) throw(). */
- fn = declare_library_fn (fn, void_type_node, ptr_type_node,
- ECF_NOTHROW | ECF_LEAF);
-
- if (flag_tm)
+ tree name = get_identifier ("__cxa_free_exception");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
{
- tree fn2 = get_identifier ("_ITM_cxa_free_exception");
- if (!get_global_value_if_present (fn2, &fn2))
- fn2 = declare_library_fn (fn2, void_type_node,
- ptr_type_node,
- ECF_NOTHROW | ECF_LEAF | ECF_TM_PURE);
- record_tm_replacement (fn, fn2);
+ /* Declare void __cxa_free_exception (void *) throw(). */
+ fn = declare_library_fn (name, void_type_node, ptr_type_node,
+ ECF_NOTHROW | ECF_LEAF);
+
+ if (flag_tm)
+ {
+ tree itm_name = get_identifier ("_ITM_cxa_free_exception");
+ tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ if (!itm_fn)
+ itm_fn = declare_library_fn
+ (itm_name, void_type_node, ptr_type_node,
+ ECF_NOTHROW | ECF_LEAF | ECF_TM_PURE);
+ record_tm_replacement (fn, itm_fn);
+ }
}
}
tree
build_throw (tree exp)
{
- tree fn;
-
if (exp == error_mark_node)
return exp;
if (exp)
{
+ static tree throw_fn;
tree throw_type;
tree temp_type;
tree cleanup;
cleanup_type = build_pointer_type (tmp);
}
- fn = get_identifier ("__cxa_throw");
- if (!get_global_value_if_present (fn, &fn))
+ if (!throw_fn)
{
- /* Declare void __cxa_throw (void*, void*, void (*)(void*)). */
- /* ??? Second argument is supposed to be "std::type_info*". */
- tmp = build_function_type_list (void_type_node,
- ptr_type_node, ptr_type_node,
- cleanup_type, NULL_TREE);
- fn = push_throw_library_fn (fn, tmp);
-
- if (flag_tm)
+ tree name = get_identifier ("__cxa_throw");
+ throw_fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!throw_fn)
{
- tree fn2 = get_identifier ("_ITM_cxa_throw");
- if (!get_global_value_if_present (fn2, &fn2))
- fn2 = push_throw_library_fn (fn2, tmp);
- apply_tm_attr (fn2, get_identifier ("transaction_pure"));
- record_tm_replacement (fn, fn2);
+ /* Declare void __cxa_throw (void*, void*, void (*)(void*)). */
+ /* ??? Second argument is supposed to be "std::type_info*". */
+ tmp = build_function_type_list (void_type_node,
+ ptr_type_node, ptr_type_node,
+ cleanup_type, NULL_TREE);
+ throw_fn = push_throw_library_fn (name, tmp);
+
+ if (flag_tm)
+ {
+ tree itm_name = get_identifier ("_ITM_cxa_throw");
+ tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ if (!itm_fn)
+ itm_fn = push_throw_library_fn (itm_name, tmp);
+ apply_tm_attr (itm_fn, get_identifier ("transaction_pure"));
+ record_tm_replacement (throw_fn, itm_fn);
+ }
}
}
cleanup = NULL_TREE;
if (type_build_dtor_call (TREE_TYPE (object)))
{
- tree fn = lookup_fnfields (TYPE_BINFO (TREE_TYPE (object)),
- complete_dtor_identifier, 0);
- fn = BASELINK_FUNCTIONS (fn);
- mark_used (fn);
+ tree dtor_fn = lookup_fnfields (TYPE_BINFO (TREE_TYPE (object)),
+ complete_dtor_identifier, 0);
+ dtor_fn = BASELINK_FUNCTIONS (dtor_fn);
+ mark_used (dtor_fn);
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (object)))
{
- cxx_mark_addressable (fn);
+ cxx_mark_addressable (dtor_fn);
/* Pretend it's a normal function. */
- cleanup = build1 (ADDR_EXPR, cleanup_type, fn);
+ cleanup = build1 (ADDR_EXPR, cleanup_type, dtor_fn);
}
}
if (cleanup == NULL_TREE)
cleanup = build_int_cst (cleanup_type, 0);
/* ??? Indicate that this function call throws throw_type. */
- tmp = cp_build_function_call_nary (fn, tf_warning_or_error,
+ tmp = cp_build_function_call_nary (throw_fn, tf_warning_or_error,
ptr, throw_type, cleanup, NULL_TREE);
/* Tack on the initialization stuff. */
else
{
/* Rethrow current exception. */
+ static tree rethrow_fn;
- tree fn = get_identifier ("__cxa_rethrow");
- if (!get_global_value_if_present (fn, &fn))
+ if (!rethrow_fn)
{
- /* Declare void __cxa_rethrow (void). */
- fn = push_throw_library_fn
- (fn, build_function_type_list (void_type_node, NULL_TREE));
- }
+ tree name = get_identifier ("__cxa_rethrow");
+ rethrow_fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!rethrow_fn)
+ /* Declare void __cxa_rethrow (void). */
+ rethrow_fn = push_throw_library_fn
+ (name, build_function_type_list (void_type_node, NULL_TREE));
- if (flag_tm)
- apply_tm_attr (fn, get_identifier ("transaction_pure"));
+ if (flag_tm)
+ apply_tm_attr (rethrow_fn, get_identifier ("transaction_pure"));
+ }
/* ??? Indicate that this function call allows exceptions of the type
of the enclosing catch block (if known). */
- exp = cp_build_function_call_vec (fn, NULL, tf_warning_or_error);
+ exp = cp_build_function_call_vec (rethrow_fn, NULL, tf_warning_or_error);
}
exp = build1 (THROW_EXPR, void_type_node, exp);
tree
throw_bad_array_new_length (void)
{
- tree fn = get_identifier ("__cxa_throw_bad_array_new_length");
- if (!get_global_value_if_present (fn, &fn))
- fn = push_throw_library_fn (fn, build_function_type_list (sizetype,
- NULL_TREE));
+ static tree fn;
+ if (!fn)
+ {
+ tree name = get_identifier ("__cxa_throw_bad_array_new_length");
+
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
+ fn = push_throw_library_fn
+ (name, build_function_type_list (sizetype, NULL_TREE));
+ }
return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
}
static cp_binding_level *innermost_nonclass_level (void);
static void set_identifier_type_value_with_scope (tree id, tree decl,
cp_binding_level *b);
+static void set_namespace_binding (tree name, tree scope, tree val);
+
/* The bindings for a particular name in a particular scope. */
struct scope_binding {
if (arg_assoc_namespace (k, TREE_PURPOSE (value)))
return true;
- value = namespace_binding (k->name, scope);
+ value = get_namespace_value (scope, k->name);
if (!value)
return false;
/* In case this decl was explicitly namespace-qualified, look it
up in its namespace context. */
if (DECL_NAMESPACE_SCOPE_P (x) && namespace_bindings_p ())
- t = namespace_binding (name, DECL_CONTEXT (x));
+ t = get_namespace_value (DECL_CONTEXT (x), name);
else
t = lookup_name_innermost_nonclass_level (name);
t = innermost_non_namespace_value (name);
/* Or in the innermost namespace. */
if (! t)
- t = namespace_binding (name, DECL_CONTEXT (x));
+ t = get_namespace_value (DECL_CONTEXT (x), name);
/* Does it have linkage? Note that if this isn't a DECL, it's an
OVERLOAD, which is OK. */
if (t && DECL_P (t) && ! (TREE_STATIC (t) || DECL_EXTERNAL (t)))
{
tree decl;
- decl = IDENTIFIER_NAMESPACE_VALUE (name);
+ decl = get_namespace_value (current_namespace, name);
if (decl && TREE_CODE (decl) == OVERLOAD)
decl = OVL_FUNCTION (decl);
|| TREE_CODE (x) == NAMESPACE_DECL
|| TREE_CODE (x) == CONST_DECL
|| TREE_CODE (x) == TEMPLATE_DECL))
- SET_IDENTIFIER_NAMESPACE_VALUE (name, x);
+ set_namespace_binding (name, current_namespace, x);
/* If new decl is `static' and an `extern' was seen previously,
warn about it. */
else
{
/* Here to install a non-global value. */
- tree oldglobal = IDENTIFIER_NAMESPACE_VALUE (name);
+ tree oldglobal = get_namespace_value (current_namespace, name);
tree oldlocal = NULL_TREE;
cp_binding_level *oldscope = NULL;
cxx_binding *oldbinding = outer_binding (name, NULL, true);
oldlocal = DECL_SHADOWED_FOR_VAR (oldlocal);
if (oldlocal == NULL_TREE)
- oldlocal = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (d));
+ oldlocal
+ = get_namespace_value (current_namespace, DECL_NAME (d));
}
/* If this is an extern function declaration, see if we
shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (shadowed)
? DECL_SHADOWED_FOR_VAR (shadowed) : NULL_TREE;
if (!shadowed)
- shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (decl));
+ shadowed = get_namespace_value (current_namespace, DECL_NAME (decl));
if (shadowed)
{
if (!DECL_ERROR_REPORTED (decl))
int doing_global = (namespace_bindings_p () || !(flags & PUSH_LOCAL));
if (doing_global)
- old = namespace_binding (name, DECL_CONTEXT (decl));
+ old = get_namespace_value (DECL_CONTEXT (decl), name);
else
old = lookup_name_innermost_nonclass_level (name);
return binding ? binding->value : NULL_TREE;
}
+/* Return the binding for NAME in NS. If NS is NULL, look in
+ global_namespace. */
+
tree
-namespace_binding (tree name, tree scope)
+get_namespace_value (tree ns, tree name)
{
- tree ret;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- ret = namespace_binding_1 (name, scope);
+ if (!ns)
+ ns = global_namespace;
+ tree ret = namespace_binding_1 (name, ns);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return ret;
}
-/* Set the binding value for name in scope. */
-
static void
-set_namespace_binding_1 (tree name, tree scope, tree val)
+set_namespace_binding (tree name, tree scope, tree val)
{
cxx_binding *b;
supplement_binding (b, val);
}
-/* Wrapper for set_namespace_binding_1. */
+/* Set NAME in the global namespace to VAL. Does not add it to the
+ list of things in the namespace. */
void
-set_namespace_binding (tree name, tree scope, tree val)
+set_global_value (tree name, tree val)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- set_namespace_binding_1 (name, scope, val);
+
+ set_namespace_binding (name, global_namespace, val);
+
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
if (b->kind == sk_namespace)
{
- t = IDENTIFIER_NAMESPACE_VALUE (name);
+ t = get_namespace_value (current_namespace, name);
/* extern "C" function() */
if (t != NULL_TREE && TREE_CODE (t) == TREE_LIST)
if (anon)
{
name = anon_identifier;
- d = IDENTIFIER_NAMESPACE_VALUE (name);
+ d = get_namespace_value (current_namespace, name);
if (d)
/* Reopening anonymous namespace. */
need_new = false;
else
{
/* Check whether this is an extended namespace definition. */
- d = IDENTIFIER_NAMESPACE_VALUE (name);
+ d = get_namespace_value (current_namespace, name);
if (d != NULL_TREE && TREE_CODE (d) == NAMESPACE_DECL)
{
tree dna = DECL_NAMESPACE_ALIAS (d);
extern tree lookup_name_prefer_type (tree, int);
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);
-extern void set_namespace_binding (tree, tree, tree);
+extern tree get_namespace_value (tree ns, tree id);
+extern void set_global_value (tree id, tree val);
extern bool hidden_name_p (tree);
extern tree remove_hidden_names (tree);
extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false);
extern cxx_binding *outer_binding (tree, cxx_binding *, bool);
extern void cp_emit_debug_info_for_using (tree, tree);
-/* Set *DECL to the (non-hidden) declaration for ID at global scope,
- if present and return true; otherwise return false. */
-
-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. */
-
-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 */
static tree
listify (tree arg)
{
- tree std_init_list = namespace_binding (init_list_identifier, std_node);
+ tree std_init_list = get_namespace_value (std_node, init_list_identifier);
tree argvec;
if (!std_init_list || !DECL_CLASS_TEMPLATE_P (std_init_list))
{
static tree
throw_bad_cast (void)
{
- tree fn = get_identifier ("__cxa_bad_cast");
- if (!get_global_value_if_present (fn, &fn))
- fn = push_throw_library_fn (fn, build_function_type_list (ptr_type_node,
- NULL_TREE));
+ static tree fn;
+ if (!fn)
+ {
+ tree name = get_identifier ("__cxa_bad_cast");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
+ fn = push_throw_library_fn
+ (name, build_function_type_list (ptr_type_node, NULL_TREE));
+ }
return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
}
static tree
throw_bad_typeid (void)
{
- tree fn = get_identifier ("__cxa_bad_typeid");
- if (!get_global_value_if_present (fn, &fn))
+ static tree fn;
+ if (!fn)
{
- tree t;
-
- t = build_reference_type (const_type_info_type_node);
- t = build_function_type_list (t, NULL_TREE);
- fn = push_throw_library_fn (fn, t);
+ tree name = get_identifier ("__cxa_bad_typeid");
+ fn = IDENTIFIER_GLOBAL_VALUE (name);
+ if (!fn)
+ {
+ tree t = build_reference_type (const_type_info_type_node);
+ t = build_function_type_list (t, NULL_TREE);
+ fn = push_throw_library_fn (name, t);
+ }
}
return build_cxx_call (fn, 0, NULL, tf_warning_or_error);