* C++ patch ping @ 2018-07-13 13:49 Jakub Jelinek 2018-07-13 16:24 ` Nathan Sidwell 2018-07-13 16:42 ` C++ patch ping Nathan Sidwell 0 siblings, 2 replies; 9+ messages in thread From: Jakub Jelinek @ 2018-07-13 13:49 UTC (permalink / raw) To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches Hi! I'd like to ping the following C++ patches: - PR c++/85515 make range for temporaries unspellable during parsing and only turn them into spellable for debug info purposes http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00086.html - PR c++/3698, PR c++/86208 extern_decl_map & TREE_USED fix (plus 2 untested variants) http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00084.html Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ patch ping 2018-07-13 13:49 C++ patch ping Jakub Jelinek @ 2018-07-13 16:24 ` Nathan Sidwell 2018-07-13 16:53 ` Jakub Jelinek 2018-07-13 16:42 ` C++ patch ping Nathan Sidwell 1 sibling, 1 reply; 9+ messages in thread From: Nathan Sidwell @ 2018-07-13 16:24 UTC (permalink / raw) To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches On 07/13/2018 09:49 AM, Jakub Jelinek wrote: > Hi! > > I'd like to ping the following C++ patches: > > - PR c++/85515 > make range for temporaries unspellable during parsing and only > turn them into spellable for debug info purposes > http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00086.html How hard would it be to add the 6 special identifiers to the C++ global table via initialize_predefined_identifiers (decl.c) and then use them directly in the for range machinery? repeated get_identifier ("string-const") just smells bad. nathan -- Nathan Sidwell ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ patch ping 2018-07-13 16:24 ` Nathan Sidwell @ 2018-07-13 16:53 ` Jakub Jelinek 2018-07-18 10:19 ` [C++ PATCH] Hide __for_{range,begin,end} symbols (PR c++/85515, take 2) Jakub Jelinek 0 siblings, 1 reply; 9+ messages in thread From: Jakub Jelinek @ 2018-07-13 16:53 UTC (permalink / raw) To: Nathan Sidwell; +Cc: Jason Merrill, gcc-patches On Fri, Jul 13, 2018 at 12:24:02PM -0400, Nathan Sidwell wrote: > On 07/13/2018 09:49 AM, Jakub Jelinek wrote: > > Hi! > > > > I'd like to ping the following C++ patches: > > > > - PR c++/85515 > > make range for temporaries unspellable during parsing and only > > turn them into spellable for debug info purposes > > http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00086.html > > > How hard would it be to add the 6 special identifiers to the C++ global > table via initialize_predefined_identifiers (decl.c) and then use them > directly in the for range machinery? repeated get_identifier > ("string-const") just smells bad. Probably not too hard, but we have hundreds of other get_identifier ("string-const") calls in the middle-end, C++ FE, other FEs. Are those 6 more important than say "abi_tag", "gnu", "begin", "end", "get", "tuple_size", "tuple_element", and many others? Is it worth caching those? Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* [C++ PATCH] Hide __for_{range,begin,end} symbols (PR c++/85515, take 2) 2018-07-13 16:53 ` Jakub Jelinek @ 2018-07-18 10:19 ` Jakub Jelinek 2018-07-18 21:05 ` [C++ PATCH] Further get_identifier ("string literal") C++ FE caching Jakub Jelinek 0 siblings, 1 reply; 9+ messages in thread From: Jakub Jelinek @ 2018-07-18 10:19 UTC (permalink / raw) To: Nathan Sidwell; +Cc: Jason Merrill, gcc-patches On Fri, Jul 13, 2018 at 06:53:30PM +0200, Jakub Jelinek wrote: > On Fri, Jul 13, 2018 at 12:24:02PM -0400, Nathan Sidwell wrote: > > On 07/13/2018 09:49 AM, Jakub Jelinek wrote: > > > Hi! > > > > > > I'd like to ping the following C++ patches: > > > > > > - PR c++/85515 > > > make range for temporaries unspellable during parsing and only > > > turn them into spellable for debug info purposes > > > http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00086.html > > > > > > How hard would it be to add the 6 special identifiers to the C++ global > > table via initialize_predefined_identifiers (decl.c) and then use them > > directly in the for range machinery? repeated get_identifier > > ("string-const") just smells bad. > > Probably not too hard, but we have hundreds of other > get_identifier ("string-const") calls in the middle-end, C++ FE, other FEs. > Are those 6 more important than say "abi_tag", "gnu", "begin", "end", "get", > "tuple_size", "tuple_element", and many others? > > Is it worth caching those? Anyway, here is an updated patch that uses the get_identifier caching. Ok for trunk? Shall I submit an incremental patch for the "abi_tag", "gnu", "begin", "end", "get", "tuple_size", "tuple_element" etc. identifiers? 2018-07-18 Jakub Jelinek <jakub@redhat.com> PR c++/85515 * cp-tree.h (enum cp_tree_index): Add CPTI_FOR_{RANGE,BEGIN,END}{,_}_IDENTIFIER. (for_range__identifier, for_begin__identifier, for_end__identifier, for_range_identifier, for_begin_identifier, for_end_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize for_{range,begin,end}{,_}_identifier. * parser.c (build_range_temp): Use for_range__identifier instead of get_identifier ("__for_range"). (cp_convert_range_for): Use for_begin__identifier and for_end__identifier instead of get_identifier ("__for_begin") and get_identifier ("__for_end"). * semantics.c (finish_for_stmt): Rename "__for_{range,begin,end} " local symbols to "__for_{range,begin,end}". * g++.dg/pr85515-2.C: Add expected dg-error. * g++.dg/cpp0x/range-for36.C: New test. --- gcc/cp/cp-tree.h.jj 2018-06-29 09:38:17.790306399 +0200 +++ gcc/cp/cp-tree.h 2018-07-18 11:57:55.980529748 +0200 @@ -154,6 +154,12 @@ enum cp_tree_index CPTI_AUTO_IDENTIFIER, CPTI_DECLTYPE_AUTO_IDENTIFIER, CPTI_INIT_LIST_IDENTIFIER, + CPTI_FOR_RANGE__IDENTIFIER, + CPTI_FOR_BEGIN__IDENTIFIER, + CPTI_FOR_END__IDENTIFIER, + CPTI_FOR_RANGE_IDENTIFIER, + CPTI_FOR_BEGIN_IDENTIFIER, + CPTI_FOR_END_IDENTIFIER, CPTI_LANG_NAME_C, CPTI_LANG_NAME_CPLUSPLUS, @@ -274,6 +280,12 @@ extern GTY(()) tree cp_global_trees[CPTI #define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER] #define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER] #define init_list_identifier cp_global_trees[CPTI_INIT_LIST_IDENTIFIER] +#define for_range__identifier cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER] +#define for_begin__identifier cp_global_trees[CPTI_FOR_BEGIN__IDENTIFIER] +#define for_end__identifier cp_global_trees[CPTI_FOR_END__IDENTIFIER] +#define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER] +#define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER] +#define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER] #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] --- gcc/cp/decl.c.jj 2018-07-12 21:34:44.798598796 +0200 +++ gcc/cp/decl.c 2018-07-18 11:59:06.220595473 +0200 @@ -4044,6 +4044,12 @@ initialize_predefined_identifiers (void) {"auto", &auto_identifier, cik_normal}, {"decltype(auto)", &decltype_auto_identifier, cik_normal}, {"initializer_list", &init_list_identifier, cik_normal}, + {"__for_range ", &for_range__identifier, cik_normal}, + {"__for_begin ", &for_begin__identifier, cik_normal}, + {"__for_end ", &for_end__identifier, cik_normal}, + {"__for_range", &for_range_identifier, cik_normal}, + {"__for_begin", &for_begin_identifier, cik_normal}, + {"__for_end", &for_end_identifier, cik_normal}, {NULL, NULL, cik_normal} }; --- gcc/cp/parser.c.jj 2018-07-18 10:09:10.655030931 +0200 +++ gcc/cp/parser.c 2018-07-18 12:00:22.907667232 +0200 @@ -11952,8 +11952,8 @@ build_range_temp (tree range_expr) type_uses_auto (range_type)); /* Create the __range variable. */ - range_temp = build_decl (input_location, VAR_DECL, - get_identifier ("__for_range"), range_type); + range_temp = build_decl (input_location, VAR_DECL, for_range__identifier, + range_type); TREE_USED (range_temp) = 1; DECL_ARTIFICIAL (range_temp) = 1; @@ -12060,8 +12060,8 @@ cp_convert_range_for (tree statement, tr } /* The new for initialization statement. */ - begin = build_decl (input_location, VAR_DECL, - get_identifier ("__for_begin"), iter_type); + begin = build_decl (input_location, VAR_DECL, for_begin__identifier, + iter_type); TREE_USED (begin) = 1; DECL_ARTIFICIAL (begin) = 1; pushdecl (begin); @@ -12071,8 +12071,7 @@ cp_convert_range_for (tree statement, tr if (cxx_dialect >= cxx17) iter_type = cv_unqualified (TREE_TYPE (end_expr)); - end = build_decl (input_location, VAR_DECL, - get_identifier ("__for_end"), iter_type); + end = build_decl (input_location, VAR_DECL, for_end__identifier, iter_type); TREE_USED (end) = 1; DECL_ARTIFICIAL (end) = 1; pushdecl (end); --- gcc/cp/semantics.c.jj 2018-07-10 09:11:24.254062152 +0200 +++ gcc/cp/semantics.c 2018-07-18 12:03:24.482837137 +0200 @@ -1060,7 +1060,35 @@ finish_for_stmt (tree for_stmt) : &FOR_SCOPE (for_stmt)); tree scope = *scope_ptr; *scope_ptr = NULL; + + /* During parsing of the body, range for uses "__for_{range,begin,end} " + decl names to make those unaccessible by code in the body. + Change it to ones with underscore instead of space, so that it can + be inspected in the debugger. */ + tree range_for_decl[3] = { NULL_TREE, NULL_TREE, NULL_TREE }; + gcc_assert (CPTI_FOR_BEGIN__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 1 + && CPTI_FOR_END__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 2 + && CPTI_FOR_RANGE_IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 3 + && CPTI_FOR_BEGIN_IDENTIFIER == CPTI_FOR_BEGIN__IDENTIFIER + 3 + && CPTI_FOR_END_IDENTIFIER == CPTI_FOR_END__IDENTIFIER + 3); + for (int i = 0; i < 3; i++) + { + tree id = cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER + i]; + if (IDENTIFIER_BINDING (id) + && IDENTIFIER_BINDING (id)->scope == current_binding_level) + { + range_for_decl[i] = IDENTIFIER_BINDING (id)->value; + gcc_assert (VAR_P (range_for_decl[i]) + && DECL_ARTIFICIAL (range_for_decl[i])); + } + } + add_stmt (do_poplevel (scope)); + + for (int i = 0; i < 3; i++) + if (range_for_decl[i]) + DECL_NAME (range_for_decl[i]) + = cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER + i]; } /* Begin a range-for-statement. Returns a new RANGE_FOR_STMT. --- gcc/testsuite/g++.dg/pr85515-2.C.jj 2018-07-05 11:41:51.439718304 +0200 +++ gcc/testsuite/g++.dg/pr85515-2.C 2018-07-18 11:27:36.452850086 +0200 @@ -15,8 +15,7 @@ int test_2 () int sum = 0; for (const auto v: arr) { sum += v; - // TODO: should we issue an error for the following assignment? - __for_begin = __for_end; + __for_begin = __for_end; // { dg-error "was not declared in this scope" } } return sum; } --- gcc/testsuite/g++.dg/cpp0x/range-for36.C.jj 2018-07-18 11:27:36.452850086 +0200 +++ gcc/testsuite/g++.dg/cpp0x/range-for36.C 2018-07-18 11:27:36.452850086 +0200 @@ -0,0 +1,32 @@ +// PR c++/85515 +// { dg-do compile { target c++11 } } + +int a[10]; + +void +foo () +{ + for (auto &i : a) + if (i != *__for_begin // { dg-error "was not declared in this scope" } + || &i == __for_end // { dg-error "was not declared in this scope" } + || &__for_range[0] != &a[0]) // { dg-error "was not declared in this scope" } + __builtin_abort (); +} + +template <int N> +void +bar () +{ + for (auto &i : a) + if (i != *__for_begin // { dg-error "was not declared in this scope" } + || &i == __for_end // { dg-error "was not declared in this scope" } + || &__for_range[0] != &a[0]) // { dg-error "was not declared in this scope" } + __builtin_abort (); +} + +void +baz () +{ + foo (); + bar <0> (); +} Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* [C++ PATCH] Further get_identifier ("string literal") C++ FE caching 2018-07-18 10:19 ` [C++ PATCH] Hide __for_{range,begin,end} symbols (PR c++/85515, take 2) Jakub Jelinek @ 2018-07-18 21:05 ` Jakub Jelinek 2018-07-18 22:00 ` Nathan Sidwell 0 siblings, 1 reply; 9+ messages in thread From: Jakub Jelinek @ 2018-07-18 21:05 UTC (permalink / raw) To: Nathan Sidwell; +Cc: Jason Merrill, gcc-patches On Wed, Jul 18, 2018 at 12:19:31PM +0200, Jakub Jelinek wrote: > Shall I submit an incremental patch for the "abi_tag", "gnu", "begin", "end", "get", > "tuple_size", "tuple_element" etc. identifiers? Here it is in an incremental patch. I've tried to do it only for get_identifier ("string literal") calls that can be called many times during parsing rather than just at most once, and aren't related to -fgnu-tm, -fopenmp, Obj-C++ or vtv. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-07-18 Jakub Jelinek <jakub@redhat.com> * cp-tree.h (enum cp_tree_index): Add CPTI_{ABI_TAG,ALIGNED,BEGIN,END,GET,TUPLE_{ELEMENT,SIZE}}_IDENTIFIER and CPTI_{GNU,TYPE,VALUE,FUN,CLOSURE}_IDENTIFIER. (abi_tag_identifier, aligned_identifier, begin_identifier, end_identifier, get__identifier, gnu_identifier, tuple_element_identifier, tuple_size_identifier, type_identifier, value_identifier, fun_identifier, closure_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize the above identifiers. (get_tuple_size): Use tuple_size_identifier instead of get_identifier ("tuple_size") and value_identifier instead of get_identifier ("value"). (get_tuple_element_type): Use tuple_element_identifier instead of get_identifier ("tuple_element") and type_identifier instead of get_identifier ("type"). (get_tuple_decomp_init): Use get__identifier instead of get_identifier ("get"). * lambda.c (maybe_add_lambda_conv_op): Use fun_identifier instead of get_identifier ("_FUN"). * parser.c (cp_parser_lambda_declarator_opt): Use closure_identifier instead of get_identifier ("__closure"). (cp_parser_std_attribute): Use gnu_identifier instead of get_identifier ("gnu"). (cp_parser_std_attribute_spec): Likewise. Use aligned_identifier instead of get_identifier ("aligned"). * class.c (check_abi_tags, inherit_targ_abi_tags): Use abi_tag_identifier instead of get_identifier ("abi_tag"). --- gcc/cp/cp-tree.h.jj 2018-07-18 11:57:55.980529748 +0200 +++ gcc/cp/cp-tree.h 2018-07-18 18:52:44.805248036 +0200 @@ -160,6 +160,18 @@ enum cp_tree_index CPTI_FOR_RANGE_IDENTIFIER, CPTI_FOR_BEGIN_IDENTIFIER, CPTI_FOR_END_IDENTIFIER, + CPTI_ABI_TAG_IDENTIFIER, + CPTI_ALIGNED_IDENTIFIER, + CPTI_BEGIN_IDENTIFIER, + CPTI_END_IDENTIFIER, + CPTI_GET_IDENTIFIER, + CPTI_GNU_IDENTIFIER, + CPTI_TUPLE_ELEMENT_IDENTIFIER, + CPTI_TUPLE_SIZE_IDENTIFIER, + CPTI_TYPE_IDENTIFIER, + CPTI_VALUE_IDENTIFIER, + CPTI_FUN_IDENTIFIER, + CPTI_CLOSURE_IDENTIFIER, CPTI_LANG_NAME_C, CPTI_LANG_NAME_CPLUSPLUS, @@ -286,6 +298,18 @@ extern GTY(()) tree cp_global_trees[CPTI #define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER] #define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER] #define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER] +#define abi_tag_identifier cp_global_trees[CPTI_ABI_TAG_IDENTIFIER] +#define aligned_identifier cp_global_trees[CPTI_ALIGNED_IDENTIFIER] +#define begin_identifier cp_global_trees[CPTI_BEGIN_IDENTIFIER] +#define end_identifier cp_global_trees[CPTI_END_IDENTIFIER] +#define get__identifier cp_global_trees[CPTI_GET_IDENTIFIER] +#define gnu_identifier cp_global_trees[CPTI_GNU_IDENTIFIER] +#define tuple_element_identifier cp_global_trees[CPTI_TUPLE_ELEMENT_IDENTIFIER] +#define tuple_size_identifier cp_global_trees[CPTI_TUPLE_SIZE_IDENTIFIER] +#define type_identifier cp_global_trees[CPTI_TYPE_IDENTIFIER] +#define value_identifier cp_global_trees[CPTI_VALUE_IDENTIFIER] +#define fun_identifier cp_global_trees[CPTI_FUN_IDENTIFIER] +#define closure_identifier cp_global_trees[CPTI_CLOSURE_IDENTIFIER] #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] --- gcc/cp/decl.c.jj 2018-07-18 11:59:06.220595473 +0200 +++ gcc/cp/decl.c 2018-07-18 18:52:58.676265952 +0200 @@ -4050,6 +4050,18 @@ initialize_predefined_identifiers (void) {"__for_range", &for_range_identifier, cik_normal}, {"__for_begin", &for_begin_identifier, cik_normal}, {"__for_end", &for_end_identifier, cik_normal}, + {"abi_tag", &abi_tag_identifier, cik_normal}, + {"aligned", &aligned_identifier, cik_normal}, + {"begin", &begin_identifier, cik_normal}, + {"end", &end_identifier, cik_normal}, + {"get", &get__identifier, cik_normal}, + {"gnu", &gnu_identifier, cik_normal}, + {"tuple_element", &tuple_element_identifier, cik_normal}, + {"tuple_size", &tuple_size_identifier, cik_normal}, + {"type", &type_identifier, cik_normal}, + {"value", &value_identifier, cik_normal}, + {"_FUN", &fun_identifier, cik_normal}, + {"__closure", &closure_identifier, cik_normal}, {NULL, NULL, cik_normal} }; @@ -7334,14 +7346,14 @@ get_tuple_size (tree type) { tree args = make_tree_vec (1); TREE_VEC_ELT (args, 0) = type; - tree inst = lookup_template_class (get_identifier ("tuple_size"), args, + tree inst = lookup_template_class (tuple_size_identifier, args, /*in_decl*/NULL_TREE, /*context*/std_node, /*entering_scope*/false, tf_none); inst = complete_type (inst); if (inst == error_mark_node || !COMPLETE_TYPE_P (inst)) return NULL_TREE; - tree val = lookup_qualified_name (inst, get_identifier ("value"), + tree val = lookup_qualified_name (inst, value_identifier, /*type*/false, /*complain*/false); if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL) val = maybe_constant_value (val); @@ -7359,12 +7371,12 @@ get_tuple_element_type (tree type, unsig tree args = make_tree_vec (2); TREE_VEC_ELT (args, 0) = build_int_cst (integer_type_node, i); TREE_VEC_ELT (args, 1) = type; - tree inst = lookup_template_class (get_identifier ("tuple_element"), args, + tree inst = lookup_template_class (tuple_element_identifier, args, /*in_decl*/NULL_TREE, /*context*/std_node, /*entering_scope*/false, tf_warning_or_error); - return make_typename_type (inst, get_identifier ("type"), + return make_typename_type (inst, type_identifier, none_type, tf_warning_or_error); } @@ -7373,7 +7385,6 @@ get_tuple_element_type (tree type, unsig static tree get_tuple_decomp_init (tree decl, unsigned i) { - tree get_id = get_identifier ("get"); tree targs = make_tree_vec (1); TREE_VEC_ELT (targs, 0) = build_int_cst (integer_type_node, i); @@ -7386,7 +7397,7 @@ get_tuple_decomp_init (tree decl, unsign || TYPE_REF_IS_RVALUE (etype)) e = move (e); - tree fns = lookup_qualified_name (TREE_TYPE (e), get_id, + tree fns = lookup_qualified_name (TREE_TYPE (e), get__identifier, /*type*/false, /*complain*/false); bool use_member_get = false; @@ -7418,7 +7429,7 @@ get_tuple_decomp_init (tree decl, unsign else { vec<tree,va_gc> *args = make_tree_vector_single (e); - fns = lookup_template_function (get_id, targs); + fns = lookup_template_function (get__identifier, targs); fns = perform_koenig_lookup (fns, args, tf_warning_or_error); return finish_call_expr (fns, &args, /*novirt*/false, /*koenig*/true, tf_warning_or_error); --- gcc/cp/lambda.c.jj 2018-06-16 08:49:51.377795726 +0200 +++ gcc/cp/lambda.c 2018-07-18 18:50:03.840040093 +0200 @@ -1214,8 +1214,7 @@ maybe_add_lambda_conv_op (tree type) /* Now build up the thunk to be returned. */ - name = get_identifier ("_FUN"); - tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype); + tree statfn = build_lang_decl (FUNCTION_DECL, fun_identifier, stattype); SET_DECL_LANGUAGE (statfn, lang_cplusplus); fn = statfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); --- gcc/cp/parser.c.jj 2018-07-18 12:00:22.907667232 +0200 +++ gcc/cp/parser.c 2018-07-18 18:50:46.361095022 +0200 @@ -10638,7 +10638,7 @@ cp_parser_lambda_declarator_opt (cp_pars DECL_INITIALIZED_IN_CLASS_P (fco) = 1; DECL_ARTIFICIAL (fco) = 1; /* Give the object parameter a different name. */ - DECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier ("__closure"); + DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier; } if (template_param_list) { @@ -25341,13 +25341,13 @@ cp_parser_std_attribute (cp_parser *pars NULL_TREE); /* C++11 noreturn attribute is equivalent to GNU's. */ if (is_attribute_p ("noreturn", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* C++14 deprecated attribute is equivalent to GNU's. */ else if (is_attribute_p ("deprecated", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* C++17 fallthrough attribute is equivalent to GNU's. */ else if (is_attribute_p ("fallthrough", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* Transactional Memory TS optimize_for_synchronized attribute is equivalent to GNU transaction_callable. */ else if (is_attribute_p ("optimize_for_synchronized", attr_id)) @@ -25367,7 +25367,7 @@ cp_parser_std_attribute (cp_parser *pars vec<tree, va_gc> *vec; int attr_flag = normal_attr; - if (attr_ns == get_identifier ("gnu") + if (attr_ns == gnu_identifier && attribute_takes_identifier_p (attr_id)) /* A GNU attribute that takes an identifier in parameter. */ attr_flag = id_attr; @@ -25580,10 +25580,9 @@ cp_parser_std_attribute_spec (cp_parser /* Build the C++-11 representation of an 'aligned' attribute. */ - attributes = - build_tree_list (build_tree_list (get_identifier ("gnu"), - get_identifier ("aligned")), - alignas_expr); + attributes + = build_tree_list (build_tree_list (gnu_identifier, + aligned_identifier), alignas_expr); } return attributes; --- gcc/cp/class.c.jj 2018-07-16 23:24:23.326390997 +0200 +++ gcc/cp/class.c 2018-07-18 18:39:49.184244081 +0200 @@ -1517,8 +1517,7 @@ check_abi_tags (tree t, tree subob, bool TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); else DECL_ATTRIBUTES (t) - = tree_cons (get_identifier ("abi_tag"), data.tags, - DECL_ATTRIBUTES (t)); + = tree_cons (abi_tag_identifier, data.tags, DECL_ATTRIBUTES (t)); } mark_abi_tags (t, false); @@ -1590,8 +1589,7 @@ inherit_targ_abi_tags (tree t) TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); else TYPE_ATTRIBUTES (t) - = tree_cons (get_identifier ("abi_tag"), data.tags, - TYPE_ATTRIBUTES (t)); + = tree_cons (abi_tag_identifier, data.tags, TYPE_ATTRIBUTES (t)); } mark_abi_tags (t, false); Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] Further get_identifier ("string literal") C++ FE caching 2018-07-18 21:05 ` [C++ PATCH] Further get_identifier ("string literal") C++ FE caching Jakub Jelinek @ 2018-07-18 22:00 ` Nathan Sidwell 2018-07-18 22:43 ` Jakub Jelinek 0 siblings, 1 reply; 9+ messages in thread From: Nathan Sidwell @ 2018-07-18 22:00 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches So cool! Thanks. Sorry for the top posting nathan-- Nathan Sidwell -------- Original message --------From: Jakub Jelinek <jakub@redhat.com> Date: 7/18/18 17:04 (GMT-05:00) To: Nathan Sidwell <nathan@acm.org> Cc: Jason Merrill <jason@redhat.com>, gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Further get_identifier ("string literal") C++ FE caching On Wed, Jul 18, 2018 at 12:19:31PM +0200, Jakub Jelinek wrote: > Shall I submit an incremental patch for the "abi_tag", "gnu", "begin", "end", "get", > "tuple_size", "tuple_element" etc. identifiers? Here it is in an incremental patch. I've tried to do it only for get_identifier ("string literal") calls that can be called many times during parsing rather than just at most once, and aren't related to -fgnu-tm, -fopenmp, Obj-C++ or vtv. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-07-18 Jakub Jelinek <jakub@redhat.com> * cp-tree.h (enum cp_tree_index): Add CPTI_{ABI_TAG,ALIGNED,BEGIN,END,GET,TUPLE_{ELEMENT,SIZE}}_IDENTIFIER and CPTI_{GNU,TYPE,VALUE,FUN,CLOSURE}_IDENTIFIER. (abi_tag_identifier, aligned_identifier, begin_identifier, end_identifier, get__identifier, gnu_identifier, tuple_element_identifier, tuple_size_identifier, type_identifier, value_identifier, fun_identifier, closure_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize the above identifiers. (get_tuple_size): Use tuple_size_identifier instead of get_identifier ("tuple_size") and value_identifier instead of get_identifier ("value"). (get_tuple_element_type): Use tuple_element_identifier instead of get_identifier ("tuple_element") and type_identifier instead of get_identifier ("type"). (get_tuple_decomp_init): Use get__identifier instead of get_identifier ("get"). * lambda.c (maybe_add_lambda_conv_op): Use fun_identifier instead of get_identifier ("_FUN"). * parser.c (cp_parser_lambda_declarator_opt): Use closure_identifier instead of get_identifier ("__closure"). (cp_parser_std_attribute): Use gnu_identifier instead of get_identifier ("gnu"). (cp_parser_std_attribute_spec): Likewise. Use aligned_identifier instead of get_identifier ("aligned"). * class.c (check_abi_tags, inherit_targ_abi_tags): Use abi_tag_identifier instead of get_identifier ("abi_tag"). --- gcc/cp/cp-tree.h.jj 2018-07-18 11:57:55.980529748 +0200 +++ gcc/cp/cp-tree.h 2018-07-18 18:52:44.805248036 +0200 @@ -160,6 +160,18 @@ enum cp_tree_index CPTI_FOR_RANGE_IDENTIFIER, CPTI_FOR_BEGIN_IDENTIFIER, CPTI_FOR_END_IDENTIFIER, + CPTI_ABI_TAG_IDENTIFIER, + CPTI_ALIGNED_IDENTIFIER, + CPTI_BEGIN_IDENTIFIER, + CPTI_END_IDENTIFIER, + CPTI_GET_IDENTIFIER, + CPTI_GNU_IDENTIFIER, + CPTI_TUPLE_ELEMENT_IDENTIFIER, + CPTI_TUPLE_SIZE_IDENTIFIER, + CPTI_TYPE_IDENTIFIER, + CPTI_VALUE_IDENTIFIER, + CPTI_FUN_IDENTIFIER, + CPTI_CLOSURE_IDENTIFIER, CPTI_LANG_NAME_C, CPTI_LANG_NAME_CPLUSPLUS, @@ -286,6 +298,18 @@ extern GTY(()) tree cp_global_trees[CPTI #define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER] #define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER] #define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER] +#define abi_tag_identifier cp_global_trees[CPTI_ABI_TAG_IDENTIFIER] +#define aligned_identifier cp_global_trees[CPTI_ALIGNED_IDENTIFIER] +#define begin_identifier cp_global_trees[CPTI_BEGIN_IDENTIFIER] +#define end_identifier cp_global_trees[CPTI_END_IDENTIFIER] +#define get__identifier cp_global_trees[CPTI_GET_IDENTIFIER] +#define gnu_identifier cp_global_trees[CPTI_GNU_IDENTIFIER] +#define tuple_element_identifier cp_global_trees[CPTI_TUPLE_ELEMENT_IDENTIFIER] +#define tuple_size_identifier cp_global_trees[CPTI_TUPLE_SIZE_IDENTIFIER] +#define type_identifier cp_global_trees[CPTI_TYPE_IDENTIFIER] +#define value_identifier cp_global_trees[CPTI_VALUE_IDENTIFIER] +#define fun_identifier cp_global_trees[CPTI_FUN_IDENTIFIER] +#define closure_identifier cp_global_trees[CPTI_CLOSURE_IDENTIFIER] #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] --- gcc/cp/decl.c.jj 2018-07-18 11:59:06.220595473 +0200 +++ gcc/cp/decl.c 2018-07-18 18:52:58.676265952 +0200 @@ -4050,6 +4050,18 @@ initialize_predefined_identifiers (void) {"__for_range", &for_range_identifier, cik_normal}, {"__for_begin", &for_begin_identifier, cik_normal}, {"__for_end", &for_end_identifier, cik_normal}, + {"abi_tag", &abi_tag_identifier, cik_normal}, + {"aligned", &aligned_identifier, cik_normal}, + {"begin", &begin_identifier, cik_normal}, + {"end", &end_identifier, cik_normal}, + {"get", &get__identifier, cik_normal}, + {"gnu", &gnu_identifier, cik_normal}, + {"tuple_element", &tuple_element_identifier, cik_normal}, + {"tuple_size", &tuple_size_identifier, cik_normal}, + {"type", &type_identifier, cik_normal}, + {"value", &value_identifier, cik_normal}, + {"_FUN", &fun_identifier, cik_normal}, + {"__closure", &closure_identifier, cik_normal}, {NULL, NULL, cik_normal} }; @@ -7334,14 +7346,14 @@ get_tuple_size (tree type) { tree args = make_tree_vec (1); TREE_VEC_ELT (args, 0) = type; - tree inst = lookup_template_class (get_identifier ("tuple_size"), args, + tree inst = lookup_template_class (tuple_size_identifier, args, /*in_decl*/NULL_TREE, /*context*/std_node, /*entering_scope*/false, tf_none); inst = complete_type (inst); if (inst == error_mark_node || !COMPLETE_TYPE_P (inst)) return NULL_TREE; - tree val = lookup_qualified_name (inst, get_identifier ("value"), + tree val = lookup_qualified_name (inst, value_identifier, /*type*/false, /*complain*/false); if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL) val = maybe_constant_value (val); @@ -7359,12 +7371,12 @@ get_tuple_element_type (tree type, unsig tree args = make_tree_vec (2); TREE_VEC_ELT (args, 0) = build_int_cst (integer_type_node, i); TREE_VEC_ELT (args, 1) = type; - tree inst = lookup_template_class (get_identifier ("tuple_element"), args, + tree inst = lookup_template_class (tuple_element_identifier, args, /*in_decl*/NULL_TREE, /*context*/std_node, /*entering_scope*/false, tf_warning_or_error); - return make_typename_type (inst, get_identifier ("type"), + return make_typename_type (inst, type_identifier, none_type, tf_warning_or_error); } @@ -7373,7 +7385,6 @@ get_tuple_element_type (tree type, unsig static tree get_tuple_decomp_init (tree decl, unsigned i) { - tree get_id = get_identifier ("get"); tree targs = make_tree_vec (1); TREE_VEC_ELT (targs, 0) = build_int_cst (integer_type_node, i); @@ -7386,7 +7397,7 @@ get_tuple_decomp_init (tree decl, unsign || TYPE_REF_IS_RVALUE (etype)) e = move (e); - tree fns = lookup_qualified_name (TREE_TYPE (e), get_id, + tree fns = lookup_qualified_name (TREE_TYPE (e), get__identifier, /*type*/false, /*complain*/false); bool use_member_get = false; @@ -7418,7 +7429,7 @@ get_tuple_decomp_init (tree decl, unsign else { vec<tree,va_gc> *args = make_tree_vector_single (e); - fns = lookup_template_function (get_id, targs); + fns = lookup_template_function (get__identifier, targs); fns = perform_koenig_lookup (fns, args, tf_warning_or_error); return finish_call_expr (fns, &args, /*novirt*/false, /*koenig*/true, tf_warning_or_error); --- gcc/cp/lambda.c.jj 2018-06-16 08:49:51.377795726 +0200 +++ gcc/cp/lambda.c 2018-07-18 18:50:03.840040093 +0200 @@ -1214,8 +1214,7 @@ maybe_add_lambda_conv_op (tree type) /* Now build up the thunk to be returned. */ - name = get_identifier ("_FUN"); - tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype); + tree statfn = build_lang_decl (FUNCTION_DECL, fun_identifier, stattype); SET_DECL_LANGUAGE (statfn, lang_cplusplus); fn = statfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); --- gcc/cp/parser.c.jj 2018-07-18 12:00:22.907667232 +0200 +++ gcc/cp/parser.c 2018-07-18 18:50:46.361095022 +0200 @@ -10638,7 +10638,7 @@ cp_parser_lambda_declarator_opt (cp_pars DECL_INITIALIZED_IN_CLASS_P (fco) = 1; DECL_ARTIFICIAL (fco) = 1; /* Give the object parameter a different name. */ - DECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier ("__closure"); + DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier; } if (template_param_list) { @@ -25341,13 +25341,13 @@ cp_parser_std_attribute (cp_parser *pars NULL_TREE); /* C++11 noreturn attribute is equivalent to GNU's. */ if (is_attribute_p ("noreturn", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* C++14 deprecated attribute is equivalent to GNU's. */ else if (is_attribute_p ("deprecated", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* C++17 fallthrough attribute is equivalent to GNU's. */ else if (is_attribute_p ("fallthrough", attr_id)) - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + TREE_PURPOSE (TREE_PURPOSE (attribute)) = gnu_identifier; /* Transactional Memory TS optimize_for_synchronized attribute is equivalent to GNU transaction_callable. */ else if (is_attribute_p ("optimize_for_synchronized", attr_id)) @@ -25367,7 +25367,7 @@ cp_parser_std_attribute (cp_parser *pars vec<tree, va_gc> *vec; int attr_flag = normal_attr; - if (attr_ns == get_identifier ("gnu") + if (attr_ns == gnu_identifier && attribute_takes_identifier_p (attr_id)) /* A GNU attribute that takes an identifier in parameter. */ attr_flag = id_attr; @@ -25580,10 +25580,9 @@ cp_parser_std_attribute_spec (cp_parser /* Build the C++-11 representation of an 'aligned' attribute. */ - attributes = - build_tree_list (build_tree_list (get_identifier ("gnu"), - get_identifier ("aligned")), - alignas_expr); + attributes + = build_tree_list (build_tree_list (gnu_identifier, + aligned_identifier), alignas_expr); } return attributes; --- gcc/cp/class.c.jj 2018-07-16 23:24:23.326390997 +0200 +++ gcc/cp/class.c 2018-07-18 18:39:49.184244081 +0200 @@ -1517,8 +1517,7 @@ check_abi_tags (tree t, tree subob, bool TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); else DECL_ATTRIBUTES (t) - = tree_cons (get_identifier ("abi_tag"), data.tags, - DECL_ATTRIBUTES (t)); + = tree_cons (abi_tag_identifier, data.tags, DECL_ATTRIBUTES (t)); } mark_abi_tags (t, false); @@ -1590,8 +1589,7 @@ inherit_targ_abi_tags (tree t) TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); else TYPE_ATTRIBUTES (t) - = tree_cons (get_identifier ("abi_tag"), data.tags, - TYPE_ATTRIBUTES (t)); + = tree_cons (abi_tag_identifier, data.tags, TYPE_ATTRIBUTES (t)); } mark_abi_tags (t, false); Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] Further get_identifier ("string literal") C++ FE caching 2018-07-18 22:00 ` Nathan Sidwell @ 2018-07-18 22:43 ` Jakub Jelinek 2018-07-25 16:40 ` Nathan Sidwell 0 siblings, 1 reply; 9+ messages in thread From: Jakub Jelinek @ 2018-07-18 22:43 UTC (permalink / raw) To: Nathan Sidwell; +Cc: Jason Merrill, gcc-patches On Wed, Jul 18, 2018 at 06:00:20PM -0400, Nathan Sidwell wrote: > So cool! Thanks. Ok for both patches or just this one? Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] Further get_identifier ("string literal") C++ FE caching 2018-07-18 22:43 ` Jakub Jelinek @ 2018-07-25 16:40 ` Nathan Sidwell 0 siblings, 0 replies; 9+ messages in thread From: Nathan Sidwell @ 2018-07-25 16:40 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches On 07/18/2018 06:43 PM, Jakub Jelinek wrote: > On Wed, Jul 18, 2018 at 06:00:20PM -0400, Nathan Sidwell wrote: >> So cool! Thanks. > > Ok for both patches or just this one? both are ok, sorry for delay (vacation), thanks for doing that! nathan -- Nathan Sidwell ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ patch ping 2018-07-13 13:49 C++ patch ping Jakub Jelinek 2018-07-13 16:24 ` Nathan Sidwell @ 2018-07-13 16:42 ` Nathan Sidwell 1 sibling, 0 replies; 9+ messages in thread From: Nathan Sidwell @ 2018-07-13 16:42 UTC (permalink / raw) To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches On 07/13/2018 09:49 AM, Jakub Jelinek wrote: > - PR c++/3698, PR c++/86208 > extern_decl_map & TREE_USED fix (plus 2 untested variants) > http://gcc.gnu.org/ml/gcc-patches/2018-07/msg00084.html ok, thanks -- Nathan Sidwell ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-07-25 16:40 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-07-13 13:49 C++ patch ping Jakub Jelinek 2018-07-13 16:24 ` Nathan Sidwell 2018-07-13 16:53 ` Jakub Jelinek 2018-07-18 10:19 ` [C++ PATCH] Hide __for_{range,begin,end} symbols (PR c++/85515, take 2) Jakub Jelinek 2018-07-18 21:05 ` [C++ PATCH] Further get_identifier ("string literal") C++ FE caching Jakub Jelinek 2018-07-18 22:00 ` Nathan Sidwell 2018-07-18 22:43 ` Jakub Jelinek 2018-07-25 16:40 ` Nathan Sidwell 2018-07-13 16:42 ` C++ patch ping Nathan Sidwell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).