From 641da50a0c73f734e672f8e6b9e7d2c86bde840d Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 9 May 2017 11:17:45 +0000 Subject: [PATCH] c-tree.h (pushdecl): Declare. gcc/c/ * c-tree.h (pushdecl): Declare. gcc/cp/ * cp-lang.c (get_global_decls, cxx_pushdecl): New. (LANG_HOOKS_GETDECLS, LANG_HOOKS_PUSHDECL): Override. * name-lookup.h (pushdecl_top_level): Declare. gcc/c-family/ * c-common.c (c_register_builtin_type): Use pushdecl lang_hook. * c-common.h (pushdecl_top_level, pushdecl): Don't declare here. gcc/objc/ * objc-gnu-runtime-abi-01.c (objc_add_static_instance): Use pushdecl lang_hook. From-SVN: r247785 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-common.c | 2 +- gcc/c-family/c-common.h | 3 +-- gcc/c/ChangeLog | 4 ++++ gcc/c/c-tree.h | 1 + gcc/cp/ChangeLog | 8 +++++++- gcc/cp/cp-lang.c | 22 ++++++++++++++++++++++ gcc/cp/name-lookup.h | 2 ++ gcc/objc/ChangeLog | 5 +++++ gcc/objc/objc-gnu-runtime-abi-01.c | 2 +- 10 files changed, 49 insertions(+), 5 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7e882e1..6409442 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-05-09 Nathan Sidwell + + * c-common.c (c_register_builtin_type): Use pushdecl lang_hook. + * c-common.h (pushdecl_top_level, pushdecl): Don't declare here. + 2017-05-08 Martin Sebor PR translation/80280 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f46b254..ad686d2 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2589,7 +2589,7 @@ c_register_builtin_type (tree type, const char* name) DECL_ARTIFICIAL (decl) = 1; if (!TYPE_NAME (type)) TYPE_NAME (type) = decl; - pushdecl (decl); + lang_hooks.decls.pushdecl (decl); registered_builtin_types = tree_cons (0, type, registered_builtin_types); } diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 138a0a6..9e3982d 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -588,8 +588,7 @@ extern tree push_stmt_list (void); extern tree pop_stmt_list (tree); extern tree add_stmt (tree); extern void push_cleanup (tree, tree, bool); -extern tree pushdecl_top_level (tree); -extern tree pushdecl (tree); + extern tree build_modify_expr (location_t, tree, tree, enum tree_code, location_t, tree, tree); extern tree build_array_notation_expr (location_t, tree, tree, enum tree_code, diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 45f375fd..5d6c6ef 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,7 @@ +2017-05-09 Nathan Sidwell + + * c-tree.h (pushdecl): Declare. + 2017-05-05 David Malcolm * c-decl.c (warn_defaults_to): Replace report_diagnostic diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 5fa32a4..8d232a4 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -506,6 +506,7 @@ extern tree c_break_label; extern tree c_cont_label; extern bool global_bindings_p (void); +extern tree pushdecl (tree); extern void push_scope (void); extern tree pop_scope (void); extern void c_bindings_start_stmt_expr (struct c_spot_bindings *); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3119d5f..c4b850f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-05-09 Nathan Sidwell + + * cp-lang.c (get_global_decls, cxx_pushdecl): New. + (LANG_HOOKS_GETDECLS, LANG_HOOKS_PUSHDECL): Override. + * name-lookup.h (pushdecl_top_level): Declare. + 2017-05-08 Jason Merrill PR c++/80178 - parameter passing for uncopyable classes @@ -10,7 +16,7 @@ 2017-05-08 Nathan Sidwell - * decl.c (builtin_function_1): Set DCL_ANTICIPATED before pushing. + * decl.c (builtin_function_1): Set DECL_ANTICIPATED before pushing. (start_preparsed_function): Do decl pushing before setting current_funciton_decl and announcing it. diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index d4776a2..b5f11e3 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -35,6 +35,8 @@ static tree cp_eh_personality (void); static tree get_template_innermost_arguments_folded (const_tree); static tree get_template_argument_pack_elems_folded (const_tree); static tree cxx_enum_underlying_base_type (const_tree); +static tree get_global_decls (); +static tree cxx_pushdecl (tree); /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h; consequently, there should be very few hooks below. */ @@ -78,6 +80,10 @@ static tree cxx_enum_underlying_base_type (const_tree); #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type #undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE #define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type +#undef LANG_HOOKS_GETDECLS +#define LANG_HOOKS_GETDECLS get_global_decls +#undef LANG_HOOKS_PUSHDECL +#define LANG_HOOKS_PUSHDECL cxx_pushdecl /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; @@ -229,5 +235,21 @@ tree cxx_enum_underlying_base_type (const_tree type) return underlying_type; } +/* Return the list of decls in the global namespace. */ + +static tree +get_global_decls () +{ + return NAMESPACE_LEVEL (global_namespace)->names; +} + +/* Push DECL into the current scope. */ + +static tree +cxx_pushdecl (tree decl) +{ + return pushdecl (decl); +} + #include "gt-cp-cp-lang.h" #include "gtype-cp.h" diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 904b14e..02e37d7 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -342,4 +342,6 @@ extern tree innermost_non_namespace_value (tree); extern cxx_binding *outer_binding (tree, cxx_binding *, bool); extern void cp_emit_debug_info_for_using (tree, tree); +extern tree pushdecl_top_level (tree); + #endif /* GCC_CP_NAME_LOOKUP_H */ diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 5649ddc..88ec3b3 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2017-05-09 Nathan Sidwell + + * objc-gnu-runtime-abi-01.c (objc_add_static_instance): Use + pushdecl lang_hook. + 2017-05-04 Martin Sebor PR translation/80280 diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index beeec58..d1686e6 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -888,7 +888,7 @@ objc_add_static_instance (tree constructor, tree class_decl) /* We may be writing something else just now. Postpone till end of input. */ DECL_DEFER_OUTPUT (decl) = 1; - pushdecl_top_level (decl); + lang_hooks.decls.pushdecl (decl); rest_of_decl_compilation (decl, 1, 0); /* Add the DECL to the head of this CLASS' list. */ -- 2.7.4