diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5a842bd74d7..1db3c331948 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-05-19 Bernd Edlinger + + * c-format.c (locus): Move out of function scope, + add GTY attribute. + 2017-05-19 Nathan Sidwell * c-opts.c (class_dump_file, class_dump_flags): Delete. diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index f3a02ed6e16..a561d0e30e4 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -55,6 +55,7 @@ struct function_format_info /* Initialized in init_dynamic_diag_info. */ static GTY(()) tree local_tree_type_node; +static GTY(()) tree locus; static bool decode_format_attr (tree, function_format_info *, int); static int decode_format_type (const char *); @@ -3734,8 +3735,6 @@ init_dynamic_asm_fprintf_info (void) static void init_dynamic_gfc_info (void) { - static tree locus; - if (!locus) { static format_char_info *gfc_fci; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 08efe36f356..a8613a159ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2017-05-19 Bernd Edlinger + + * config-lang.in (gtfiles): Add c-family/c-format.c, + except.c, init.c, lambda.c and friend.c. + * class.c (dvirt_fn): Move out of function scope, + add GTY attribute. + * except.c (fn1-5, throw_fn, rethrow_fn, spec): Likewise. + * init.c (fn): Likewise. + * lambda.c (ptr_id, max_id): Likewise. + * friend.c (global_friend): Add GTY attribute. + 2017-05-19 Nathan Sidwell * call.c (add_list_candidates): Use OVL_FIRST. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c0eb945b385..984fb09ff4b 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -9547,6 +9547,7 @@ dfs_accumulate_vtbl_inits (tree binfo, } static GTY(()) tree abort_fndecl_addr; +static GTY(()) tree dvirt_fn; /* Construct the initializer for BINFO's virtual function table. BINFO is part of the hierarchy dominated by T. If we're building a @@ -9720,8 +9721,6 @@ build_vtbl_initializer (tree binfo, /* Likewise for deleted virtuals. */ else if (DECL_DELETED_FN (fn_original)) { - static tree dvirt_fn; - if (!dvirt_fn) { tree name = get_identifier ("__cxa_deleted_virtual"); diff --git a/gcc/cp/config-lang.in b/gcc/cp/config-lang.in index 1ce8cd72649..9390c96c510 100644 --- a/gcc/cp/config-lang.in +++ b/gcc/cp/config-lang.in @@ -29,4 +29,4 @@ compilers="cc1plus\$(exeext)" target_libs="target-libstdc++-v3" -gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/cp-lang.c \$(srcdir)/cp/except.c \$(srcdir)/cp/vtable-class-hierarchy.c \$(srcdir)/cp/constexpr.c \$(srcdir)/cp/cp-gimplify.c" +gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/c-family/c-format.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/cp-lang.c \$(srcdir)/cp/except.c \$(srcdir)/cp/vtable-class-hierarchy.c \$(srcdir)/cp/constexpr.c \$(srcdir)/cp/cp-gimplify.c \$(srcdir)/cp/init.c \$(srcdir)/cp/friend.c \$(srcdir)/cp/lambda.c" diff --git a/gcc/cp/except.c b/gcc/cp/except.c index b4fe07af4d0..da0be843ca7 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -42,6 +42,15 @@ static int complete_ptr_ref_or_void_ptr_p (tree, tree); static bool is_admissible_throw_operand_or_catch_parameter (tree, bool); static int can_convert_eh (tree, tree); +static GTY(()) tree fn1; +static GTY(()) tree fn2; +static GTY(()) tree fn3; +static GTY(()) tree fn4; +static GTY(()) tree fn5; +static GTY(()) tree throw_fn; +static GTY(()) tree rethrow_fn; +static GTY(()) tree spec; + /* Sets up all the global eh stuff that needs to be initialized at the start of compilation. */ @@ -154,20 +163,18 @@ declare_library_fn (tree name, tree return_type, tree parm_type, int ecf_flags) static tree do_get_exception_ptr (void) { - static tree fn; - - if (!fn) + if (!fn1) { tree name = get_identifier ("__cxa_get_exception_ptr"); - fn = IDENTIFIER_GLOBAL_VALUE (name); - if (!fn) + fn1 = IDENTIFIER_GLOBAL_VALUE (name); + if (!fn1) /* Declare void* __cxa_get_exception_ptr (void *) throw(). */ - fn = declare_library_fn + fn1 = 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, + return cp_build_function_call_nary (fn1, tf_warning_or_error, build_exc_ptr (), NULL_TREE); } @@ -177,16 +184,14 @@ do_get_exception_ptr (void) static tree do_begin_catch (void) { - static tree fn; - - if (!fn) + if (!fn2) { - tree name = fn = get_identifier ("__cxa_begin_catch"); - fn = IDENTIFIER_GLOBAL_VALUE (name); - if (!fn) + tree name = get_identifier ("__cxa_begin_catch"); + fn2 = IDENTIFIER_GLOBAL_VALUE (name); + if (!fn2) { /* Declare void* __cxa_begin_catch (void *) throw(). */ - fn = declare_library_fn + fn2 = declare_library_fn (name, ptr_type_node, ptr_type_node, ECF_NOTHROW); /* Create its transactional-memory equivalent. */ @@ -198,12 +203,12 @@ do_begin_catch (void) itm_fn = declare_library_fn (itm_name, ptr_type_node, ptr_type_node, ECF_NOTHROW | ECF_TM_PURE); - record_tm_replacement (fn, itm_fn); + record_tm_replacement (fn2, itm_fn); } } } - return cp_build_function_call_nary (fn, tf_warning_or_error, + return cp_build_function_call_nary (fn2, tf_warning_or_error, build_exc_ptr (), NULL_TREE); } @@ -231,17 +236,15 @@ dtor_nothrow (tree type) static tree do_end_catch (tree type) { - static tree fn; - - if (!fn) + if (!fn3) { tree name = get_identifier ("__cxa_end_catch"); - fn = IDENTIFIER_GLOBAL_VALUE (name); - if (!fn) + fn3 = IDENTIFIER_GLOBAL_VALUE (name); + if (!fn3) { /* 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); + fn3 = push_void_library_fn (name, void_list_node, 0); /* Create its transactional-memory equivalent. */ if (flag_tm) @@ -251,12 +254,12 @@ do_end_catch (tree type) if (!itm_fn) itm_fn = push_void_library_fn (itm_name, void_list_node, ECF_TM_PURE); - record_tm_replacement (fn, itm_fn); + record_tm_replacement (fn3, itm_fn); } } } - tree cleanup = cp_build_function_call_vec (fn, NULL, tf_warning_or_error); + tree cleanup = cp_build_function_call_vec (fn3, NULL, tf_warning_or_error); TREE_NOTHROW (cleanup) = dtor_nothrow (type); return cleanup; @@ -516,17 +519,15 @@ finish_eh_spec_block (tree raw_raises, tree eh_spec_block) static tree do_allocate_exception (tree type) { - static tree fn; - - if (!fn) + if (!fn4) { tree name = get_identifier ("__cxa_allocate_exception"); - fn = IDENTIFIER_GLOBAL_VALUE (name); - if (!fn) + fn4 = IDENTIFIER_GLOBAL_VALUE (name); + if (!fn4) { /* Declare void *__cxa_allocate_exception(size_t) throw(). */ - fn = declare_library_fn (name, ptr_type_node, size_type_node, - ECF_NOTHROW | ECF_MALLOC); + fn4 = declare_library_fn (name, ptr_type_node, size_type_node, + ECF_NOTHROW | ECF_MALLOC); if (flag_tm) { @@ -536,12 +537,12 @@ do_allocate_exception (tree type) 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); + record_tm_replacement (fn4, itm_fn); } } } - return cp_build_function_call_nary (fn, tf_warning_or_error, + return cp_build_function_call_nary (fn4, tf_warning_or_error, size_in_bytes (type), NULL_TREE); } @@ -551,17 +552,15 @@ do_allocate_exception (tree type) static tree do_free_exception (tree ptr) { - static tree fn; - - if (!fn) + if (!fn5) { tree name = get_identifier ("__cxa_free_exception"); - fn = IDENTIFIER_GLOBAL_VALUE (name); - if (!fn) + fn5 = IDENTIFIER_GLOBAL_VALUE (name); + if (!fn5) { /* Declare void __cxa_free_exception (void *) throw(). */ - fn = declare_library_fn (name, void_type_node, ptr_type_node, - ECF_NOTHROW | ECF_LEAF); + fn5 = declare_library_fn (name, void_type_node, ptr_type_node, + ECF_NOTHROW | ECF_LEAF); if (flag_tm) { @@ -571,12 +570,12 @@ do_free_exception (tree ptr) 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); + record_tm_replacement (fn5, itm_fn); } } } - return cp_build_function_call_nary (fn, tf_warning_or_error, ptr, NULL_TREE); + return cp_build_function_call_nary (fn5, tf_warning_or_error, ptr, NULL_TREE); } /* Wrap all cleanups for TARGET_EXPRs in MUST_NOT_THROW_EXPR. @@ -640,7 +639,6 @@ build_throw (tree exp) if (exp) { - static tree throw_fn; tree throw_type; tree temp_type; tree cleanup; @@ -793,8 +791,6 @@ build_throw (tree exp) else { /* Rethrow current exception. */ - static tree rethrow_fn; - if (!rethrow_fn) { tree name = get_identifier ("__cxa_rethrow"); @@ -1261,7 +1257,6 @@ build_noexcept_spec (tree expr, int complain) tree unevaluated_noexcept_spec (void) { - static tree spec; if (spec == NULL_TREE) spec = build_noexcept_spec (make_node (DEFERRED_NOEXCEPT), tf_none); return spec; diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 834a1544a54..194ee168298 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see template overload resolution results when accessibility matters (e.g. tests for an accessible member). */ -static tree global_friend; +static GTY(()) tree global_friend; /* Set the GLOBAL_FRIEND for this compilation session. It might be set multiple times, but always to the same scope. */ @@ -668,3 +668,5 @@ do_friend (tree ctype, tree declarator, tree decl, return decl; } + +#include "gt-cp-friend.h" diff --git a/gcc/cp/init.c b/gcc/cp/init.c index a905af8c85a..4ad2cae541e 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -46,6 +46,8 @@ static tree dfs_initialize_vtbl_ptrs (tree, void *); static tree build_field_list (tree, tree, int *); static int diagnose_uninitialized_cst_or_ref_member_1 (tree, tree, bool, bool); +static GTY(()) tree fn; + /* We are about to generate some complex initialization code. Conceptually, it is all a single expression. However, we may want to include conditionals, loops, and other such statement-level @@ -2402,7 +2404,6 @@ diagnose_uninitialized_cst_or_ref_member (tree type, bool using_new, bool compla tree throw_bad_array_new_length (void) { - static tree fn; if (!fn) { tree name = get_identifier ("__cxa_throw_bad_array_new_length"); @@ -4911,3 +4912,5 @@ build_vec_delete (tree base, tree maxindex, return rval; } + +#include "gt-cp-init.h" diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 9d7701fba9b..5587f6021ea 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -427,13 +427,15 @@ build_capture_proxy (tree member) return var; } +static GTY(()) tree ptr_id; +static GTY(()) tree max_id; + /* Return a struct containing a pointer and a length for lambda capture of an array of runtime length. */ static tree vla_capture_type (tree array_type) { - static tree ptr_id, max_id; tree type = xref_tag (record_type, make_anon_name (), ts_current, false); xref_basetypes (type, NULL_TREE); type = begin_class_definition (type); @@ -1248,3 +1250,5 @@ is_lambda_ignored_entity (tree val) return false; } + +#include "gt-cp-lambda.h"