- tree structname = DECL_NAME (TYPE_NAME (type));
- Identifier *ident
- = Identifier::idPool (IDENTIFIER_POINTER (structname));
-
- /* Neither the `object' and `gcc.builtins' modules will not exist when
- this is called. Use a stub 'object' module parent in the meantime.
- If `gcc.builtins' is later imported, the parent will be overridden
- with the correct module symbol. */
- static Identifier *object = Identifier::idPool ("object");
- static Module *stubmod = Module::create ("object.d", object, 0, 0);
-
- StructDeclaration *sdecl = StructDeclaration::create (Loc (), ident,
- false);
- sdecl->parent = stubmod;
- sdecl->structsize = int_size_in_bytes (type);
- sdecl->alignsize = TYPE_ALIGN_UNIT (type);
- sdecl->alignment = STRUCTALIGN_DEFAULT;
- sdecl->sizeok = SIZEOKdone;
- sdecl->type = (TypeStruct::create (sdecl))->addMod (mod);
- sdecl->type->ctype = type;
- sdecl->type->merge2 ();
-
- /* Does not seem necessary to convert fields, but the members field
- must be non-null for the above size setting to stick. */
- sdecl->members = new Dsymbols;
- dtype = sdecl->type;
- builtin_converted_decls.safe_push (builtin_data (dtype, type, sdecl));
- return dtype;
+ Type *ftype = build_frontend_type (TREE_TYPE (field));
+ if (!ftype)
+ {
+ delete sdecl->members;
+ return NULL;
+ }
+
+ Identifier *fident
+ = Identifier::idPool (IDENTIFIER_POINTER (DECL_NAME (field)));
+ VarDeclaration *vd = VarDeclaration::create (Loc (), ftype, fident,
+ NULL);
+ vd->offset = tree_to_uhwi (DECL_FIELD_OFFSET (field));
+ vd->semanticRun = PASSsemanticdone;
+ vd->csym = field;
+ sdecl->members->push (vd);
+ sdecl->fields.push (vd);