From: Nathan Sidwell Date: Thu, 24 Oct 2019 00:59:57 +0000 (+0000) Subject: [C++ PATCH] 'std' identifier not needed X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5a7c45058271ab8a41462a483e696e0f2480b91a;p=gcc.git [C++ PATCH] 'std' identifier not needed https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01707.html * cp-tree.c (CPTI_STD_IDENTIFIER): Delete. (std_identifier): Delete. (DECL_NAME_SPACE_STD_P): Compare against std_node. * decl.c (initialize_predefined_identifiers): 'std' is not needed. (cxx_init_decl_processing): Adjust creation of ::std. Use {push,pop}_nested_namespace. (cxx_builtin_function): Use {push,pop}_nested_namespace. * except.c (init_exception_processing): Likewise. * rtti.c (init_rtti_processing): Likewise. From-SVN: r277365 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f587f15ddd7..dcf192a7af9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2019-10-23 Nathan Sidwell + + * cp-tree.c (CPTI_STD_IDENTIFIER): Delete. + (std_identifier): Delete. + (DECL_NAME_SPACE_STD_P): Compare against std_node. + * decl.c (initialize_predefined_identifiers): 'std' is not needed. + (cxx_init_decl_processing): Adjust creation of ::std. Use + {push,pop}_nested_namespace. + (cxx_builtin_function): Use {push,pop}_nested_namespace. + * except.c (init_exception_processing): Likewise. + * rtti.c (init_rtti_processing): Likewise. + 2019-10-23 Jason Merrill Implement P1286R2, Contra CWG1778 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e9d54466289..e307ac8d9fd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -149,7 +149,6 @@ enum cp_tree_index CPTI_PFN_IDENTIFIER, CPTI_VPTR_IDENTIFIER, CPTI_GLOBAL_IDENTIFIER, - CPTI_STD_IDENTIFIER, CPTI_ANON_IDENTIFIER, CPTI_AUTO_IDENTIFIER, CPTI_DECLTYPE_AUTO_IDENTIFIER, @@ -289,7 +288,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; #define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER] /* The name of the ::, std & anon namespaces. */ #define global_identifier cp_global_trees[CPTI_GLOBAL_IDENTIFIER] -#define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER] #define anon_identifier cp_global_trees[CPTI_ANON_IDENTIFIER] /* auto and declspec(auto) identifiers. */ #define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER] @@ -3335,9 +3333,7 @@ struct GTY(()) lang_decl { /* Nonzero if NODE is the std namespace. */ #define DECL_NAMESPACE_STD_P(NODE) \ - (TREE_CODE (NODE) == NAMESPACE_DECL \ - && CP_DECL_CONTEXT (NODE) == global_namespace \ - && DECL_NAME (NODE) == std_identifier) + ((NODE) == std_node) /* In a TREE_LIST in an attribute list, indicates that the attribute must be applied at instantiation time. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7df4ff96527..5d51442362c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4178,7 +4178,6 @@ initialize_predefined_identifiers (void) {"_vptr", &vptr_identifier, cik_normal}, {"__vtt_parm", &vtt_parm_identifier, cik_normal}, {"::", &global_identifier, cik_normal}, - {"std", &std_identifier, cik_normal}, /* The demangler expects anonymous namespaces to be called something starting with '_GLOBAL__N_'. It no longer needs to be unique to the TU. */ @@ -4262,7 +4261,7 @@ cxx_init_decl_processing (void) current_lang_name = lang_name_c; /* Create the `std' namespace. */ - push_namespace (std_identifier); + push_namespace (get_identifier ("std")); std_node = current_namespace; pop_namespace (); @@ -4392,14 +4391,14 @@ cxx_init_decl_processing (void) tree bad_alloc_type_node; tree bad_alloc_decl; - push_namespace (std_identifier); + push_nested_namespace (std_node); bad_alloc_id = get_identifier ("bad_alloc"); bad_alloc_type_node = make_class_type (RECORD_TYPE); TYPE_CONTEXT (bad_alloc_type_node) = current_namespace; bad_alloc_decl = create_implicit_typedef (bad_alloc_id, bad_alloc_type_node); DECL_CONTEXT (bad_alloc_decl) = current_namespace; - pop_namespace (); + pop_nested_namespace (std_node); new_eh_spec = add_exception_specifier (NULL_TREE, bad_alloc_type_node, -1); @@ -4451,11 +4450,11 @@ cxx_init_decl_processing (void) if (aligned_new_threshold) { - push_namespace (std_identifier); + push_nested_namespace (std_node); tree align_id = get_identifier ("align_val_t"); align_type_node = start_enum (align_id, NULL_TREE, size_type_node, NULL_TREE, /*scoped*/true, NULL); - pop_namespace (); + pop_nested_namespace (std_node); /* operator new (size_t, align_val_t); */ newtype = build_function_type_list (ptr_type_node, size_type_node, @@ -4663,10 +4662,10 @@ cxx_builtin_function (tree decl) { tree std_decl = copy_decl (decl); - push_namespace (std_identifier); + push_nested_namespace (std_node); DECL_CONTEXT (std_decl) = FROB_CONTEXT (std_node); pushdecl (std_decl); - pop_namespace (); + pop_nested_namespace (std_node); } DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 1f87c5ab695..025262c1737 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -51,14 +51,14 @@ init_exception_processing (void) tree tmp; /* void std::terminate (); */ - push_namespace (std_identifier); + push_nested_namespace (std_node); tmp = build_function_type_list (void_type_node, NULL_TREE); terminate_fn = build_cp_library_fn_ptr ("terminate", tmp, ECF_NOTHROW | ECF_NORETURN | ECF_COLD); gcc_checking_assert (TREE_THIS_VOLATILE (terminate_fn) && TREE_NOTHROW (terminate_fn)); - pop_namespace (); + pop_nested_namespace (std_node); /* void __cxa_call_unexpected(void *); */ tmp = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index c905799481e..b3d579fc7c3 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -168,10 +168,10 @@ init_rtti_processing (void) { tree type_info_type; - push_namespace (std_identifier); + push_nested_namespace (std_node); type_info_type = xref_tag (class_type, get_identifier ("type_info"), /*tag_scope=*/ts_current, false); - pop_namespace (); + pop_nested_namespace (std_node); const_type_info_type_node = cp_build_qualified_type (type_info_type, TYPE_QUAL_CONST); type_info_ptr_type = build_pointer_type (const_type_info_type_node);