From 7daef9aceb80787d9fd64b4e110b175b4d9e5a9e Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 28 May 2019 13:31:16 +0000 Subject: [PATCH] Commonize anon-name generation https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01699.html * tree.h (IDENTIFIER_ANON_P): New. (anon_aggrname_format, anon_aggname_p): Don't declare. (make_anon_name): Declare. * lto-streamer-out.c (DFS::DFS_write_tree_body): Use IDENTIFIER_ANON_P. (hash_tree): Likewise. * tree-streamer-out.c (write_ts_decl_minimal_tree): Likewise. * tree.c (anon_aggrname_p, anon_aggrname_format): Delete. (anon_cnt, make_anon_name): New. gcc/cp/ * cp-tree.h (make_anon_name): Drop declaration. (TYPE_UNNAMED_P): Use IDENTIFIER_ANON_P. * cp-lang.c (cxx_dwarf_name): Likewise. * class.c (find_flexarrays): Likewise. * decl.c (name_unnamed_type, xref_tag_1): Likewise. * error.c (dump_aggr_type): Likewise. * pt.c (push_template_decl_real): Likewise. * name-lookup.c (consider_binding_level): Likewise. (anon_cnt, make_anon_name): Delete. gcc/d/ * types.cc (fixup_anonymous_offset): Use IDENTIFIER_ANON_P. (layout_aggregate_members): Use make_anon_name. From-SVN: r271702 --- gcc/d/ChangeLog | 5 +++++ gcc/d/types.cc | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'gcc/d') diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index b6ac2f8..800dcb0 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,8 @@ +2019-05-24 Nathan Sidwell + + * types.cc (fixup_anonymous_offset): Use IDENTIFIER_ANON_P. + (layout_aggregate_members): Use make_anon_name. + 2019-05-16 Martin Sebor * d-builtins.cc (d_init_builtins): Quote keywords, operators, diff --git a/gcc/d/types.cc b/gcc/d/types.cc index cdbfbb7..8f0aa37 100644 --- a/gcc/d/types.cc +++ b/gcc/d/types.cc @@ -239,7 +239,7 @@ fixup_anonymous_offset (tree fields, tree offset) /* Traverse all nested anonymous aggregates to update their offset. Set the anonymous decl offset to its first member. */ tree ftype = TREE_TYPE (fields); - if (TYPE_NAME (ftype) && anon_aggrname_p (TYPE_IDENTIFIER (ftype))) + if (TYPE_NAME (ftype) && IDENTIFIER_ANON_P (TYPE_IDENTIFIER (ftype))) { tree vfields = TYPE_FIELDS (ftype); fixup_anonymous_offset (vfields, offset); @@ -324,12 +324,7 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p) AnonDeclaration *ad = sym->isAnonDeclaration (); if (ad != NULL) { - /* Use a counter to create anonymous type names. */ - static int anon_cnt = 0; - char buf[32]; - sprintf (buf, anon_aggrname_format (), anon_cnt++); - - tree ident = get_identifier (buf); + tree ident = make_anon_name (); tree type = make_node (ad->isunion ? UNION_TYPE : RECORD_TYPE); ANON_AGGR_TYPE_P (type) = 1; d_keep (type); -- cgit v1.1