From 638ba8121dd2042469c4b0051539c6bb8d3a5845 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 18 Oct 2019 12:46:01 +0000 Subject: [PATCH] [C++ PATCH] anon type names https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01354.html I noticed that we use a bitfield flag to note types with names for linkage purposes: typedef struct {} foo; but, we can infer this by comparing TYPE_STUB_DECL and TYPE_DECL of the main variant. It's only checked in two places -- the C++ parser and the objective C++ encoder. * cp-tree.h (struct lang_type): Remove was_anonymous. (TYPE_WAS_UNNAMED): Implement by checking TYPE_DECL & TYPE_STUB_DECL. * decl.c (name_unnamed_type): Don't set TYPE_WAS_UNNAMED. From-SVN: r277155 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-tree.h | 15 +++++++++------ gcc/cp/decl.c | 3 --- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d07a5e5..ba533d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-10-18 Nathan Sidwell + + * cp-tree.h (struct lang_type): Remove was_anonymous. + (TYPE_WAS_UNNAMED): Implement by checking TYPE_DECL & + TYPE_STUB_DECL. + * decl.c (name_unnamed_type): Don't set TYPE_WAS_UNNAMED. + 2019-10-17 Paolo Carlini * decl.c (grokfndecl): Remove redundant use of in_system_header_at. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 663d84b..8c11ac5 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2152,7 +2152,6 @@ struct GTY(()) lang_type { unsigned fields_readonly : 1; unsigned ptrmemfunc_flag : 1; - unsigned was_anonymous : 1; unsigned lazy_default_ctor : 1; unsigned lazy_copy_ctor : 1; unsigned lazy_copy_assign : 1; @@ -2160,8 +2159,8 @@ struct GTY(()) lang_type { unsigned has_const_copy_ctor : 1; unsigned has_complex_copy_ctor : 1; unsigned has_complex_copy_assign : 1; - unsigned non_aggregate : 1; + unsigned has_complex_dflt : 1; unsigned has_list_ctor : 1; unsigned non_std_layout : 1; @@ -2169,8 +2168,8 @@ struct GTY(()) lang_type { unsigned lazy_move_ctor : 1; unsigned lazy_move_assign : 1; unsigned has_complex_move_ctor : 1; - unsigned has_complex_move_assign : 1; + unsigned has_constexpr_ctor : 1; unsigned unique_obj_representations : 1; unsigned unique_obj_representations_set : 1; @@ -2182,7 +2181,7 @@ struct GTY(()) lang_type { /* There are some bits left to fill out a 32-bit word. Keep track of this by updating the size of this bitfield whenever you add or remove a flag. */ - unsigned dummy : 4; + unsigned dummy : 5; tree primary_base; vec *vcall_indices; @@ -4585,8 +4584,12 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) /* Define fields and accessors for nodes representing declared names. */ -/* Nonzero if TYPE is an unnamed class with a typedef for linkage purposes. */ -#define TYPE_WAS_UNNAMED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous) +/* True if TYPE is an unnamed structured type with a typedef for + linkage purposes. In that case TYPE_NAME and TYPE_STUB_DECL of the + MAIN-VARIANT are different. */ +#define TYPE_WAS_UNNAMED(NODE) \ + (TYPE_NAME (TYPE_MAIN_VARIANT (NODE)) \ + != TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE))) /* C++: all of these are overloaded! These apply only to TYPE_DECLs. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 35fa9e9..52f1f02 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10441,9 +10441,6 @@ name_unnamed_type (tree type, tree decl) /*debug_hooks->set_name (t, decl);*/ TYPE_NAME (t) = decl; - if (TYPE_LANG_SPECIFIC (type)) - TYPE_WAS_UNNAMED (type) = 1; - /* If this is a typedef within a template class, the nested type is a (non-primary) template. The name for the template needs updating as well. */ -- 2.7.4