public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2616] d: Use Identifier::idPool to generate anonymous field name.
@ 2021-07-30 10:55 Iain Buclaw
0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-07-30 10:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3b52a1086c1358a7694ebe0c7610058c48e93b22
commit r12-2616-g3b52a1086c1358a7694ebe0c7610058c48e93b22
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Mon Jul 26 18:06:03 2021 +0200
d: Use Identifier::idPool to generate anonymous field name.
The self-hosted implementation of the D front-end does not export
Identifier::generateId, so handle name generation inline instead.
gcc/d/ChangeLog:
* d-builtins.cc (build_frontend_type): Use Identifier::idPool to
generate anonymous field name.
Diff:
---
gcc/d/d-builtins.cc | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 9db46c0c5ca..328711fc745 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -241,8 +241,8 @@ build_frontend_type (tree type)
sdecl->type->merge2 ();
/* Add both named and anonymous fields as members of the struct.
- Anonymous fields still need a name in D, so call them "__pad%d". */
- int anonfield_id = 0;
+ Anonymous fields still need a name in D, so call them "__pad%u". */
+ unsigned anonfield_id = 0;
sdecl->members = new Dsymbols;
for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
@@ -259,7 +259,11 @@ build_frontend_type (tree type)
Identifier *fident;
if (DECL_NAME (field) == NULL_TREE)
- fident = Identifier::generateId ("__pad", anonfield_id++);
+ {
+ char name[16];
+ snprintf (name, sizeof (name), "__pad%u", anonfield_id++);
+ fident = Identifier::idPool (name);
+ }
else
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (field));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-30 10:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 10:55 [gcc r12-2616] d: Use Identifier::idPool to generate anonymous field name Iain Buclaw
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).