From 3b52a1086c1358a7694ebe0c7610058c48e93b22 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 26 Jul 2021 18:06:03 +0200 Subject: [PATCH] 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. --- 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 9db46c0c5ca6..328711fc7455 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)); -- 2.47.2