CPTI_MODULE_HWM,
/* Nodes after here change during compilation, or should not be in
- the module's global tree table. */
+ the module's global tree table. Such nodes must be locatable
+ via name lookup or type-construction, as those are the only
+ cross-TU matching capabilities remaining. */
/* We must find these via the global namespace. */
CPTI_STD,
extern tree build_typename_type (tree, tree, tree, tag_types);
extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t);
extern tree make_unbound_class_template_raw (tree, tree, tree);
+extern unsigned push_abi_namespace (tree node = abi_node);
+extern void pop_abi_namespace (unsigned flags,
+ tree node = abi_node);
extern tree build_library_fn_ptr (const char *, tree, int);
extern tree build_cp_library_fn_ptr (const char *, tree, int);
extern tree push_library_fn (tree, tree, tree, int);
all declarations, including the definition and an explicit
specialization, of that function shall have an
exception-specification with the same set of type-ids. */
- if (! DECL_IS_UNDECLARED_BUILTIN (old_decl)
+ if (!DECL_IS_UNDECLARED_BUILTIN (old_decl)
+ && !DECL_IS_UNDECLARED_BUILTIN (new_decl)
&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
{
const char *const msg
using_eh_for_cleanups ();
}
+/* Enter an abi node in global-module context. returns a cookie to
+ give to pop_abi_namespace. */
+
+unsigned
+push_abi_namespace (tree node)
+{
+ push_nested_namespace (node);
+ push_visibility ("default", 2);
+ unsigned flags = module_kind;
+ module_kind = 0;
+ return flags;
+}
+
+/* Pop an abi namespace, FLAGS is the cookie push_abi_namespace gave
+ you. */
+
+void
+pop_abi_namespace (unsigned flags, tree node)
+{
+ module_kind = flags;
+ pop_visibility (2);
+ pop_nested_namespace (node);
+}
+
/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give
the decl, LOC is the location to give the decl, NAME is the
initialization string and TYPE_DEP indicates whether NAME depended
static tree
declare_global_var (tree name, tree type)
{
- tree decl;
-
- push_to_top_level ();
- decl = build_decl (input_location, VAR_DECL, name, type);
+ auto cookie = push_abi_namespace (global_namespace);
+ tree decl = build_decl (input_location, VAR_DECL, name, type);
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
- DECL_CONTEXT (decl) = FROB_CONTEXT (global_namespace);
+ DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
/* If the user has explicitly declared this variable (perhaps
because the code we are compiling is part of a low-level runtime
library), then it is possible that our declaration will be merged
with theirs by pushdecl. */
decl = pushdecl (decl);
cp_finish_decl (decl, NULL_TREE, false, NULL_TREE, 0);
- pop_from_top_level ();
+ pop_abi_namespace (cookie, global_namespace);
return decl;
}
tree fn_ptr_type;
const char *name;
bool use_aeabi_atexit;
+ tree ctx = global_namespace;
if (atexit_node)
return atexit_node;
fn_type = build_function_type_list (integer_type_node,
argtype0, argtype1, argtype2,
NULL_TREE);
+ /* ... which needs noexcept. */
+ fn_type = build_exception_variant (fn_type, noexcept_true_spec);
if (use_aeabi_atexit)
- name = "__aeabi_atexit";
+ {
+ name = "__aeabi_atexit";
+ push_to_top_level ();
+ int n = push_namespace (get_identifier ("__aeabiv1"), false);
+ ctx = current_namespace;
+ while (n--)
+ pop_namespace ();
+ pop_from_top_level ();
+ }
else
- name = "__cxa_atexit";
+ {
+ name = "__cxa_atexit";
+ ctx = abi_node;
+ }
}
else
{
/* Build the final atexit type. */
fn_type = build_function_type_list (integer_type_node,
fn_ptr_type, NULL_TREE);
+ /* ... which needs noexcept. */
+ fn_type = build_exception_variant (fn_type, noexcept_true_spec);
name = "atexit";
}
/* Now, build the function declaration. */
push_lang_context (lang_name_c);
+ auto cookie = push_abi_namespace (ctx);
atexit_fndecl = build_library_fn_ptr (name, fn_type, ECF_LEAF | ECF_NOTHROW);
+ DECL_CONTEXT (atexit_fndecl) = FROB_CONTEXT (current_namespace);
+ /* Install as hidden builtin so we're (a) more relaxed about
+ exception spec matching and (b) will not give a confusing location
+ in diagnostic and (c) won't magically appear in user-visible name
+ lookups. */
+ DECL_SOURCE_LOCATION (atexit_fndecl) = BUILTINS_LOCATION;
+ atexit_fndecl = pushdecl (atexit_fndecl, /*hiding=*/true);
+ pop_abi_namespace (cookie, ctx);
mark_used (atexit_fndecl);
pop_lang_context ();
atexit_node = decay_conversion (atexit_fndecl, tf_warning_or_error);