cp-tree.h (enum cp_tree_index): Add CPTI_{ABI_TAG,ALIGNED,BEGIN,END,GET,TUPLE_{ELEMENT,SIZE}}_IDENTIFIER and...

* 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").

From-SVN: r262976
This commit is contained in:
Jakub Jelinek 2018-07-25 18:47:18 +02:00 committed by Jakub Jelinek
parent 213f5e8acc
commit cf7fb52d95
6 changed files with 81 additions and 22 deletions

View File

@ -1,5 +1,33 @@
2018-07-25 Jakub Jelinek <jakub@redhat.com> 2018-07-25 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").
PR c++/85515 PR c++/85515
* cp-tree.h (enum cp_tree_index): Add * cp-tree.h (enum cp_tree_index): Add
CPTI_FOR_{RANGE,BEGIN,END}{,_}_IDENTIFIER. CPTI_FOR_{RANGE,BEGIN,END}{,_}_IDENTIFIER.

View File

@ -1517,8 +1517,7 @@ check_abi_tags (tree t, tree subob, bool just_checking = false)
TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr));
else else
DECL_ATTRIBUTES (t) DECL_ATTRIBUTES (t)
= tree_cons (get_identifier ("abi_tag"), data.tags, = tree_cons (abi_tag_identifier, data.tags, DECL_ATTRIBUTES (t));
DECL_ATTRIBUTES (t));
} }
mark_abi_tags (t, false); mark_abi_tags (t, false);
@ -1590,8 +1589,7 @@ inherit_targ_abi_tags (tree t)
TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr)); TREE_VALUE (attr) = chainon (data.tags, TREE_VALUE (attr));
else else
TYPE_ATTRIBUTES (t) TYPE_ATTRIBUTES (t)
= tree_cons (get_identifier ("abi_tag"), data.tags, = tree_cons (abi_tag_identifier, data.tags, TYPE_ATTRIBUTES (t));
TYPE_ATTRIBUTES (t));
} }
mark_abi_tags (t, false); mark_abi_tags (t, false);

View File

@ -160,6 +160,18 @@ enum cp_tree_index
CPTI_FOR_RANGE_IDENTIFIER, CPTI_FOR_RANGE_IDENTIFIER,
CPTI_FOR_BEGIN_IDENTIFIER, CPTI_FOR_BEGIN_IDENTIFIER,
CPTI_FOR_END_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_C,
CPTI_LANG_NAME_CPLUSPLUS, CPTI_LANG_NAME_CPLUSPLUS,
@ -286,6 +298,18 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
#define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_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_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER]
#define for_end_identifier cp_global_trees[CPTI_FOR_END_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_c cp_global_trees[CPTI_LANG_NAME_C]
#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]

View File

@ -4050,6 +4050,18 @@ initialize_predefined_identifiers (void)
{"__for_range", &for_range_identifier, cik_normal}, {"__for_range", &for_range_identifier, cik_normal},
{"__for_begin", &for_begin_identifier, cik_normal}, {"__for_begin", &for_begin_identifier, cik_normal},
{"__for_end", &for_end_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} {NULL, NULL, cik_normal}
}; };
@ -7334,14 +7346,14 @@ get_tuple_size (tree type)
{ {
tree args = make_tree_vec (1); tree args = make_tree_vec (1);
TREE_VEC_ELT (args, 0) = type; 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, /*in_decl*/NULL_TREE,
/*context*/std_node, /*context*/std_node,
/*entering_scope*/false, tf_none); /*entering_scope*/false, tf_none);
inst = complete_type (inst); inst = complete_type (inst);
if (inst == error_mark_node || !COMPLETE_TYPE_P (inst)) if (inst == error_mark_node || !COMPLETE_TYPE_P (inst))
return NULL_TREE; return NULL_TREE;
tree val = lookup_qualified_name (inst, get_identifier ("value"), tree val = lookup_qualified_name (inst, value_identifier,
/*type*/false, /*complain*/false); /*type*/false, /*complain*/false);
if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL) if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL)
val = maybe_constant_value (val); val = maybe_constant_value (val);
@ -7359,12 +7371,12 @@ get_tuple_element_type (tree type, unsigned i)
tree args = make_tree_vec (2); tree args = make_tree_vec (2);
TREE_VEC_ELT (args, 0) = build_int_cst (integer_type_node, i); TREE_VEC_ELT (args, 0) = build_int_cst (integer_type_node, i);
TREE_VEC_ELT (args, 1) = type; 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, /*in_decl*/NULL_TREE,
/*context*/std_node, /*context*/std_node,
/*entering_scope*/false, /*entering_scope*/false,
tf_warning_or_error); 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); none_type, tf_warning_or_error);
} }
@ -7373,7 +7385,6 @@ get_tuple_element_type (tree type, unsigned i)
static tree static tree
get_tuple_decomp_init (tree decl, unsigned i) get_tuple_decomp_init (tree decl, unsigned i)
{ {
tree get_id = get_identifier ("get");
tree targs = make_tree_vec (1); tree targs = make_tree_vec (1);
TREE_VEC_ELT (targs, 0) = build_int_cst (integer_type_node, i); TREE_VEC_ELT (targs, 0) = build_int_cst (integer_type_node, i);
@ -7386,7 +7397,7 @@ get_tuple_decomp_init (tree decl, unsigned i)
|| TYPE_REF_IS_RVALUE (etype)) || TYPE_REF_IS_RVALUE (etype))
e = move (e); 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); /*type*/false, /*complain*/false);
bool use_member_get = false; bool use_member_get = false;
@ -7418,7 +7429,7 @@ get_tuple_decomp_init (tree decl, unsigned i)
else else
{ {
vec<tree,va_gc> *args = make_tree_vector_single (e); 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); fns = perform_koenig_lookup (fns, args, tf_warning_or_error);
return finish_call_expr (fns, &args, /*novirt*/false, return finish_call_expr (fns, &args, /*novirt*/false,
/*koenig*/true, tf_warning_or_error); /*koenig*/true, tf_warning_or_error);

View File

@ -1214,8 +1214,7 @@ maybe_add_lambda_conv_op (tree type)
/* Now build up the thunk to be returned. */ /* Now build up the thunk to be returned. */
name = get_identifier ("_FUN"); tree statfn = build_lang_decl (FUNCTION_DECL, fun_identifier, stattype);
tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype);
SET_DECL_LANGUAGE (statfn, lang_cplusplus); SET_DECL_LANGUAGE (statfn, lang_cplusplus);
fn = statfn; fn = statfn;
DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop);

View File

@ -10638,7 +10638,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
DECL_INITIALIZED_IN_CLASS_P (fco) = 1; DECL_INITIALIZED_IN_CLASS_P (fco) = 1;
DECL_ARTIFICIAL (fco) = 1; DECL_ARTIFICIAL (fco) = 1;
/* Give the object parameter a different name. */ /* 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) if (template_param_list)
{ {
@ -25341,13 +25341,13 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
NULL_TREE); NULL_TREE);
/* C++11 noreturn attribute is equivalent to GNU's. */ /* C++11 noreturn attribute is equivalent to GNU's. */
if (is_attribute_p ("noreturn", attr_id)) 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. */ /* C++14 deprecated attribute is equivalent to GNU's. */
else if (is_attribute_p ("deprecated", attr_id)) 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. */ /* C++17 fallthrough attribute is equivalent to GNU's. */
else if (is_attribute_p ("fallthrough", attr_id)) 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 /* Transactional Memory TS optimize_for_synchronized attribute is
equivalent to GNU transaction_callable. */ equivalent to GNU transaction_callable. */
else if (is_attribute_p ("optimize_for_synchronized", attr_id)) else if (is_attribute_p ("optimize_for_synchronized", attr_id))
@ -25367,7 +25367,7 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
vec<tree, va_gc> *vec; vec<tree, va_gc> *vec;
int attr_flag = normal_attr; int attr_flag = normal_attr;
if (attr_ns == get_identifier ("gnu") if (attr_ns == gnu_identifier
&& attribute_takes_identifier_p (attr_id)) && attribute_takes_identifier_p (attr_id))
/* A GNU attribute that takes an identifier in parameter. */ /* A GNU attribute that takes an identifier in parameter. */
attr_flag = id_attr; attr_flag = id_attr;
@ -25580,10 +25580,9 @@ cp_parser_std_attribute_spec (cp_parser *parser)
/* Build the C++-11 representation of an 'aligned' /* Build the C++-11 representation of an 'aligned'
attribute. */ attribute. */
attributes = attributes
build_tree_list (build_tree_list (get_identifier ("gnu"), = build_tree_list (build_tree_list (gnu_identifier,
get_identifier ("aligned")), aligned_identifier), alignas_expr);
alignas_expr);
} }
return attributes; return attributes;