aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-05-28 13:31:16 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-05-28 13:31:16 +0000
commit7daef9aceb80787d9fd64b4e110b175b4d9e5a9e (patch)
treee8ff7e7170740fbcd3cf83d7662f6be7b2bf2ee0 /gcc/cp
parent3253d4f0266fb7aa4e70cf6afcfac9b690cfed4a (diff)
downloadgcc-7daef9aceb80787d9fd64b4e110b175b4d9e5a9e.zip
gcc-7daef9aceb80787d9fd64b4e110b175b4d9e5a9e.tar.gz
gcc-7daef9aceb80787d9fd64b4e110b175b4d9e5a9e.tar.bz2
[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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/class.c2
-rw-r--r--gcc/cp/cp-lang.c2
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/cp/error.c2
-rw-r--r--gcc/cp/name-lookup.c24
-rw-r--r--gcc/cp/pt.c2
8 files changed, 28 insertions, 36 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0c37f55..001c53e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+2019-05-28 Nathan Sidwell <nathan@acm.org>
+
+ * 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.
+
2019-05-25 Marek Polacek <polacek@redhat.com>
PR c++/90572 - wrong disambiguation in friend declaration.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index ed885a5..a2585a6 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6585,7 +6585,7 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
if (TREE_CODE (fld) == TYPE_DECL
&& DECL_IMPLICIT_TYPEDEF_P (fld)
&& CLASS_TYPE_P (TREE_TYPE (fld))
- && anon_aggrname_p (DECL_NAME (fld)))
+ && IDENTIFIER_ANON_P (DECL_NAME (fld)))
{
/* Check the nested unnamed type referenced via a typedef
independently of FMEM (since it's not a data member of
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index 9dc3659..b725dec 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -110,7 +110,7 @@ cxx_dwarf_name (tree t, int verbosity)
gcc_assert (DECL_P (t));
if (DECL_NAME (t)
- && (anon_aggrname_p (DECL_NAME (t)) || LAMBDA_TYPE_P (t)))
+ && (IDENTIFIER_ANON_P (DECL_NAME (t)) || LAMBDA_TYPE_P (t)))
return NULL;
if (verbosity >= 2)
return decl_as_dwarf_string (t,
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fb5470d..7a74fd4 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1937,7 +1937,7 @@ enum languages { lang_c, lang_cplusplus };
/* Nonzero if NODE has no name for linkage purposes. */
#define TYPE_UNNAMED_P(NODE) \
- (OVERLOAD_TYPE_P (NODE) && anon_aggrname_p (TYPE_LINKAGE_IDENTIFIER (NODE)))
+ (OVERLOAD_TYPE_P (NODE) && IDENTIFIER_ANON_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
/* The _DECL for this _TYPE. */
#define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
@@ -6350,7 +6350,6 @@ extern tree strip_fnptr_conv (tree);
/* in name-lookup.c */
extern void maybe_push_cleanup_level (tree);
-extern tree make_anon_name (void);
extern tree maybe_push_decl (tree);
extern tree current_decl_namespace (void);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 19d14a6..5b22f65 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10233,15 +10233,12 @@ name_unnamed_type (tree type, tree decl)
/* Replace the anonymous name with the real name everywhere. */
for (tree t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
- {
- if (anon_aggrname_p (TYPE_IDENTIFIER (t)))
- /* We do not rename the debug info representing the
- unnamed tagged type because the standard says in
- [dcl.typedef] that the naming applies only for
- linkage purposes. */
- /*debug_hooks->set_name (t, decl);*/
- TYPE_NAME (t) = decl;
- }
+ if (IDENTIFIER_ANON_P (TYPE_IDENTIFIER (t)))
+ /* We do not rename the debug info representing the unnamed
+ tagged type because the standard says in [dcl.typedef] that
+ the naming applies only for linkage purposes. */
+ /*debug_hooks->set_name (t, decl);*/
+ TYPE_NAME (t) = decl;
if (TYPE_LANG_SPECIFIC (type))
TYPE_WAS_UNNAMED (type) = 1;
@@ -14061,7 +14058,7 @@ xref_tag_1 (enum tag_types tag_code, tree name,
/* In case of anonymous name, xref_tag is only called to
make type node and push name. Name lookup is not required. */
tree t = NULL_TREE;
- if (scope != ts_lambda && !anon_aggrname_p (name))
+ if (scope != ts_lambda && !IDENTIFIER_ANON_P (name))
t = lookup_and_check_tag (tag_code, name, scope, template_header_p);
if (t == error_mark_node)
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 4a0aed2..5e7c36d 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -738,7 +738,7 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
name = DECL_NAME (name);
}
- if (name == 0 || anon_aggrname_p (name))
+ if (!name || IDENTIFIER_ANON_P (name))
{
if (flags & TFF_CLASS_KEY_OR_ENUM)
pp_string (pp, M_("<unnamed>"));
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0dcaf65..242e30f 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3797,25 +3797,9 @@ constructor_name_p (tree name, tree type)
return false;
}
-/* Counter used to create anonymous type names. */
-
-static GTY(()) int anon_cnt;
-
-/* Return an IDENTIFIER which can be used as a name for
- unnamed structs and unions. */
-
-tree
-make_anon_name (void)
-{
- char buf[32];
-
- sprintf (buf, anon_aggrname_format (), anon_cnt++);
- return get_identifier (buf);
-}
-
-/* This code is practically identical to that for creating
- anonymous names, but is just used for lambdas instead. This isn't really
- necessary, but it's convenient to avoid treating lambdas like other
+/* This code is practically identical to that for creating anonymous
+ names, but is just used for lambdas instead. This isn't really
+ necessary, but it's convenient to avoid mistaking lambdas for other
unnamed types. */
static GTY(()) int lambda_cnt = 0;
@@ -5982,7 +5966,7 @@ consider_binding_level (tree name, best_match <tree, const char *> &bm,
/* Don't suggest names that are for anonymous aggregate types, as
they are an implementation detail generated by the compiler. */
- if (anon_aggrname_p (suggestion))
+ if (IDENTIFIER_ANON_P (suggestion))
continue;
const char *suggestion_str = IDENTIFIER_POINTER (suggestion);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 592adfc..e52668a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5501,7 +5501,7 @@ push_template_decl_real (tree decl, bool is_friend)
if (DECL_CLASS_SCOPE_P (decl))
member_template_p = true;
if (TREE_CODE (decl) == TYPE_DECL
- && anon_aggrname_p (DECL_NAME (decl)))
+ && IDENTIFIER_ANON_P (DECL_NAME (decl)))
{
error ("template class without a name");
return error_mark_node;