]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Use Identifier::idPool to generate anonymous field name.
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 26 Jul 2021 16:06:03 +0000 (18:06 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 30 Jul 2021 10:51:35 +0000 (12:51 +0200)
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.

gcc/d/d-builtins.cc

index 9db46c0c5ca6dbaea501ef38c2bab0b4072601a2..328711fc7455939d101d640f794da6a38955acaa 100644 (file)
@@ -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));