diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-05-05 11:30:49 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-05-05 11:30:49 +0000 |
commit | 3031802941cd7d20148b5992e7ca0ceca87ed2e9 (patch) | |
tree | 0a0daba69572b7e5632109f589365d5c5cce8ab5 /gcc/cp/decl.c | |
parent | f71425227e511e736589c74879b2c80dd6717676 (diff) | |
download | gcc-3031802941cd7d20148b5992e7ca0ceca87ed2e9.zip gcc-3031802941cd7d20148b5992e7ca0ceca87ed2e9.tar.gz gcc-3031802941cd7d20148b5992e7ca0ceca87ed2e9.tar.bz2 |
Kill per-namespace static_decls.
* cp-tree.h (static_decls): Declare.
(wrapup_globals_for_namespace)
diagnose_inline_vars_for_namespace): Replace with ...
(wrapup_namespace_globals): ... this.
* decl.c (static_decls): Define.
(wrapup_globals_for_namespace)
diagnose_inline_vars_for_namespace): Replace with ...
(wrapup_namespace_globals): ... this.
(cxx_init_decl_processing): Initialize static_decls.
* decl2.c (c_parse_final_cleanups): Adjust.
* name-lookup.h (cp_binding_level): Remove static_decls member.
* name-lookup.c (add_decl_to_level): Adjust.
(begin_scope): Adjust.
((--This line, and those below, will be ignored--
M cp/cp-tree.h
M cp/name-lookup.c
M cp/name-lookup.h
M cp/ChangeLog
M cp/decl2.c
M cp/decl.c
From-SVN: r247633
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 38ba0b0..a689750 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -157,6 +157,9 @@ tree tls_aggregates; tree integer_two_node; +/* vector of static decls. */ +vec<tree, va_gc> *static_decls; + /* Used only for jumps to as-yet undefined labels, since jumps to defined labels can have their validity checked immediately. */ @@ -903,57 +906,45 @@ walk_namespaces (walk_namespaces_fn f, void* data) } /* Call wrapup_globals_declarations for the globals in NAMESPACE. */ +/* Diagnose odr-used extern inline variables without definitions + in the current TU. */ int -wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED) +wrapup_namespace_globals () { - cp_binding_level *level = NAMESPACE_LEVEL (name_space); - vec<tree, va_gc> *statics = level->static_decls; - tree *vec = statics->address (); - int len = statics->length (); - - if (warn_unused_function) + if (vec<tree, va_gc> *statics = static_decls) { tree decl; unsigned int i; - FOR_EACH_VEC_SAFE_ELT (statics, i, decl) - if (TREE_CODE (decl) == FUNCTION_DECL - && DECL_INITIAL (decl) == 0 - && DECL_EXTERNAL (decl) - && !TREE_PUBLIC (decl) - && !DECL_ARTIFICIAL (decl) - && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl) - && !TREE_NO_WARNING (decl)) - { + FOR_EACH_VEC_ELT (*statics, i, decl) + { + if (warn_unused_function + && TREE_CODE (decl) == FUNCTION_DECL + && DECL_INITIAL (decl) == 0 + && DECL_EXTERNAL (decl) + && !TREE_PUBLIC (decl) + && !DECL_ARTIFICIAL (decl) + && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl) + && !TREE_NO_WARNING (decl)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_function, "%qF declared %<static%> but never defined", decl); - TREE_NO_WARNING (decl) = 1; - } - } - - /* Write out any globals that need to be output. */ - return wrapup_global_declarations (vec, len); -} -/* Diagnose odr-used extern inline variables without definitions - in the current TU. */ -int -diagnose_inline_vars_for_namespace (tree name_space, void *) -{ - cp_binding_level *level = NAMESPACE_LEVEL (name_space); - vec<tree, va_gc> *statics = level->static_decls; - tree decl; - unsigned int i; + if (VAR_P (decl) + && DECL_EXTERNAL (decl) + && DECL_INLINE_VAR_P (decl) + && DECL_ODR_USED (decl)) + error_at (DECL_SOURCE_LOCATION (decl), + "odr-used inline variable %qD is not defined", decl); + } - FOR_EACH_VEC_SAFE_ELT (statics, i, decl) - if (VAR_P (decl) - && DECL_EXTERNAL (decl) - && DECL_INLINE_VAR_P (decl) - && DECL_ODR_USED (decl)) - error_at (DECL_SOURCE_LOCATION (decl), - "odr-used inline variable %qD is not defined", decl); + /* Clear out the list, so we don't rescan next time. */ + static_decls = NULL; + /* Write out any globals that need to be output. */ + return wrapup_global_declarations (statics->address (), + statics->length ()); + } return 0; } @@ -4097,6 +4088,9 @@ cxx_init_decl_processing (void) integer_two_node = build_int_cst (NULL_TREE, 2); + /* Guess at the initial static decls size. */ + vec_alloc (static_decls, 500); + record_builtin_type (RID_BOOL, "bool", boolean_type_node); truthvalue_type_node = boolean_type_node; truthvalue_false_node = boolean_false_node; |