From 3cabb6b0694b65c7b5ed800822ca08bd899fc1d1 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 22 May 2020 16:55:16 -0400 Subject: [PATCH] gdb: add type::fields / type::set_fields Add the `fields` and `set_fields` methods on `struct type`, in order to remove the `TYPE_FIELDS` macro. In this patch, the `TYPE_FIELDS` macro is changed to the `type::fields`, so all the call sites that use it to set the fields array are changed to use `type::set_fields`. The next patch will remove `TYPE_FIELDS` entirely. gdb/ChangeLog: * gdbtypes.h (struct type) : New methods. (TYPE_FIELDS): Use type::fields. Change all call sites that modify the propery to use type::set_fields instead. Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33 --- gdb/ChangeLog | 6 ++++++ gdb/ada-lang.c | 24 ++++++++++++--------- gdb/buildsym.c | 5 +++-- gdb/coffread.c | 22 +++++++++---------- gdb/ctfread.c | 8 +++---- gdb/dwarf2/read.c | 21 +++++++++--------- gdb/eval.c | 4 ++-- gdb/gdbtypes.c | 53 ++++++++++++++++++++++++---------------------- gdb/gdbtypes.h | 14 +++++++++++- gdb/gnu-v3-abi.c | 4 ++-- gdb/mdebugread.c | 10 ++++----- gdb/rust-lang.c | 4 ++-- gdb/stabsread.c | 21 ++++++++++-------- gdb/windows-tdep.c | 4 ++-- 14 files changed, 114 insertions(+), 86 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 44e7b1f9b5..4b4039fae3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-05-22 Simon Marchi + + * gdbtypes.h (struct type) : New methods. + (TYPE_FIELDS): Use type::fields. Change all call sites that + modify the propery to use type::set_fields instead. + 2020-05-22 Simon Marchi * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a4804e62ef..d4377a1a49 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8021,7 +8021,6 @@ empty_record (struct type *templ) struct type *type = alloc_type_copy (templ); type->set_code (TYPE_CODE_STRUCT); - TYPE_FIELDS (type) = NULL; INIT_NONE_SPECIFIC (type); type->set_name (""); TYPE_LENGTH (type) = 0; @@ -8078,9 +8077,8 @@ ada_template_to_fixed_record_type_1 (struct type *type, rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); - TYPE_FIELDS (rtype) = (struct field *) - TYPE_ALLOC (rtype, nfields * sizeof (struct field)); - memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields); + rtype->set_fields + ((struct field *) TYPE_ZALLOC (rtype, nfields * sizeof (struct field))); rtype->set_name (ada_type_name (type)); TYPE_FIXED_INSTANCE (rtype) = 1; @@ -8353,10 +8351,14 @@ template_to_static_fixed_type (struct type *type0) type->set_code (type0->code ()); INIT_NONE_SPECIFIC (type); type->set_num_fields (nfields); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, nfields * sizeof (struct field)); - memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0), + + field *fields = + ((struct field *) + TYPE_ALLOC (type, nfields * sizeof (struct field))); + memcpy (fields, TYPE_FIELDS (type0), sizeof (struct field) * nfields); + type->set_fields (fields); + type->set_name (ada_type_name (type0)); TYPE_FIXED_INSTANCE (type) = 1; TYPE_LENGTH (type) = 0; @@ -8402,10 +8404,12 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); - TYPE_FIELDS (rtype) = + + field *fields = (struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field)); - memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type), - sizeof (struct field) * nfields); + memcpy (fields, TYPE_FIELDS (type), sizeof (struct field) * nfields); + rtype->set_fields (fields); + rtype->set_name (ada_type_name (type)); TYPE_FIXED_INSTANCE (rtype) = 1; TYPE_LENGTH (rtype) = TYPE_LENGTH (type); diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b25d09b5c0..33bf6523e9 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -272,8 +272,9 @@ buildsym_compunit::finish_block_internal if (nparams > 0) { ftype->set_num_fields (nparams); - TYPE_FIELDS (ftype) = (struct field *) - TYPE_ALLOC (ftype, nparams * sizeof (struct field)); + ftype->set_fields + ((struct field *) + TYPE_ALLOC (ftype, nparams * sizeof (struct field))); iparams = 0; /* Here we want to directly access the dictionary, because diff --git a/gdb/coffread.c b/gdb/coffread.c index 6bf3abd646..9b2f638d74 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1456,12 +1456,10 @@ patch_type (struct type *type, struct type *real_type) TYPE_LENGTH (target) = TYPE_LENGTH (real_target); target->set_num_fields (real_target->num_fields ()); - TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target, - field_size); - memcpy (TYPE_FIELDS (target), - TYPE_FIELDS (real_target), - field_size); + field *fields = (struct field *) TYPE_ALLOC (target, field_size); + memcpy (fields, real_target->fields (), field_size); + target->set_fields (fields); if (real_target->name ()) { @@ -1882,7 +1880,7 @@ decode_base_type (struct coff_symbol *cs, type->set_name (NULL); INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; - TYPE_FIELDS (type) = 0; + type->set_fields (nullptr); type->set_num_fields (0); } else @@ -1902,7 +1900,7 @@ decode_base_type (struct coff_symbol *cs, type->set_name (NULL); INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; - TYPE_FIELDS (type) = 0; + type->set_fields (nullptr); type->set_num_fields (0); } else @@ -1923,7 +1921,7 @@ decode_base_type (struct coff_symbol *cs, type->set_code (TYPE_CODE_ENUM); type->set_name (NULL); TYPE_LENGTH (type) = 0; - TYPE_FIELDS (type) = 0; + type->set_fields (nullptr); type->set_num_fields (0); } else @@ -2041,8 +2039,8 @@ coff_read_struct_type (int index, int length, int lastsym, /* Now create the vector of fields, and record how big it is. */ type->set_num_fields (nfields); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, sizeof (struct field) * nfields); + type->set_fields + ((struct field *) TYPE_ALLOC (type, sizeof (struct field) * nfields)); /* Copy the saved-up fields into the field vector. */ @@ -2121,8 +2119,8 @@ coff_read_enum_type (int index, int length, int lastsym, TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT; type->set_code (TYPE_CODE_ENUM); type->set_num_fields (nsyms); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, sizeof (struct field) * nsyms); + type->set_fields + ((struct field *) TYPE_ALLOC (type, sizeof (struct field) * nsyms)); /* Find the symbols for the values and put them into the type. The symbols can be found in the symlist that we put them on diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 31f927e3bc..c0694ed312 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -309,8 +309,8 @@ attach_fields_to_type (struct ctf_field_info *fip, struct type *type) /* Record the field count, allocate space for the array of fields. */ type->set_num_fields (nfields); - TYPE_FIELDS (type) - = (struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields); + type->set_fields + ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields)); /* Copy the saved-up fields into the field vector. */ for (int i = 0; i < nfields; ++i) @@ -1143,8 +1143,8 @@ add_stt_func (struct ctf_context *ccp, unsigned long idx) /* If argc is 0, it has a "void" type. */ if (argc != 0) - TYPE_FIELDS (ftype) - = (struct field *) TYPE_ZALLOC (ftype, argc * sizeof (struct field)); + ftype->set_fields + ((struct field *) TYPE_ZALLOC (ftype, argc * sizeof (struct field))); /* TYPE_FIELD_TYPE must never be NULL. Fill it with void_type, if failed to find the argument type. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0581b8e208..08d235865b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9365,8 +9365,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) type->set_num_fields (3); /* Save the field we care about. */ struct field saved_field = TYPE_FIELD (type, 0); - TYPE_FIELDS (type) - = (struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)); + type->set_fields + ((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field))); /* Put the discriminant at index 0. */ TYPE_FIELD_TYPE (type, 0) = field_type; @@ -9460,7 +9460,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) * sizeof (struct field))); memcpy (new_fields + 1, TYPE_FIELDS (type), type->num_fields () * sizeof (struct field)); - TYPE_FIELDS (type) = new_fields; + type->set_fields (new_fields); type->set_num_fields (type->num_fields () + 1); /* Install the discriminant at index 0 in the union. */ @@ -9510,7 +9510,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) if (sub_type->num_fields () > 0) { sub_type->set_num_fields (sub_type->num_fields () - 1); - ++TYPE_FIELDS (sub_type); + sub_type->set_fields (sub_type->fields () + 1); } TYPE_FIELD_NAME (type, i) = variant_name; sub_type->set_name @@ -14805,8 +14805,8 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, /* Record the field count, allocate space for the array of fields, and create blank accessibility bitfields if necessary. */ type->set_num_fields (nfields); - TYPE_FIELDS (type) = (struct field *) - TYPE_ZALLOC (type, sizeof (struct field) * nfields); + type->set_fields + ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields)); if (fip->non_public_fields && cu->language != language_ada) { @@ -15934,8 +15934,9 @@ update_enumeration_type_from_children (struct die_info *die, if (!fields.empty ()) { type->set_num_fields (fields.size ()); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, sizeof (struct field) * fields.size ()); + type->set_fields + ((struct field *) + TYPE_ALLOC (type, sizeof (struct field) * fields.size ())); memcpy (TYPE_FIELDS (type), fields.data (), sizeof (struct field) * fields.size ()); } @@ -17085,8 +17086,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) /* Allocate storage for parameters and fill them in. */ ftype->set_num_fields (nparams); - TYPE_FIELDS (ftype) = (struct field *) - TYPE_ZALLOC (ftype, nparams * sizeof (struct field)); + ftype->set_fields + ((struct field *) TYPE_ZALLOC (ftype, nparams * sizeof (struct field))); /* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it even if we error out during the parameters reading below. */ diff --git a/gdb/eval.c b/gdb/eval.c index 8104c956b4..069cf5ddbc 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -683,8 +683,8 @@ fake_method::fake_method (type_instance_flags flags, allocate memory for auxiliary fields, and free the memory ourselves when we are done with it. */ type->set_num_fields (num_types); - TYPE_FIELDS (type) = (struct field *) - xzalloc (sizeof (struct field) * num_types); + type->set_fields + ((struct field *) xzalloc (sizeof (struct field) * num_types)); while (num_types-- > 0) TYPE_FIELD_TYPE (type, num_types) = param_types[num_types]; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 01d8530d0f..d1623457a1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -563,8 +563,8 @@ lookup_function_type_with_arguments (struct type *type, } fn->set_num_fields (nparams); - TYPE_FIELDS (fn) - = (struct field *) TYPE_ZALLOC (fn, nparams * sizeof (struct field)); + fn->set_fields + ((struct field *) TYPE_ZALLOC (fn, nparams * sizeof (struct field))); for (i = 0; i < nparams; ++i) TYPE_FIELD_TYPE (fn, i) = param_types[i]; @@ -1282,8 +1282,8 @@ create_array_type_with_stride (struct type *result_type, TYPE_TARGET_TYPE (result_type) = element_type; result_type->set_num_fields (1); - TYPE_FIELDS (result_type) = - (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)); + result_type->set_fields + ((struct field *) TYPE_ZALLOC (result_type, sizeof (struct field))); TYPE_INDEX_TYPE (result_type) = range_type; if (byte_stride_prop != NULL) result_type->add_dyn_prop (DYN_PROP_BYTE_STRIDE, *byte_stride_prop); @@ -1381,8 +1381,8 @@ create_set_type (struct type *result_type, struct type *domain_type) result_type->set_code (TYPE_CODE_SET); result_type->set_num_fields (1); - TYPE_FIELDS (result_type) - = (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)); + result_type->set_fields + ((struct field *) TYPE_ZALLOC (result_type, sizeof (struct field))); if (!TYPE_STUB (domain_type)) { @@ -1549,7 +1549,7 @@ smash_to_method_type (struct type *type, struct type *self_type, type->set_code (TYPE_CODE_METHOD); TYPE_TARGET_TYPE (type) = to_type; set_type_self_type (type, self_type); - TYPE_FIELDS (type) = args; + type->set_fields (args); type->set_num_fields (nargs); if (varargs) TYPE_VARARGS (type) = 1; @@ -2238,10 +2238,10 @@ resolve_dynamic_union (struct type *type, gdb_assert (type->code () == TYPE_CODE_UNION); resolved_type = copy_type (type); - TYPE_FIELDS (resolved_type) - = (struct field *) TYPE_ALLOC (resolved_type, - resolved_type->num_fields () - * sizeof (struct field)); + resolved_type->set_fields + ((struct field *) + TYPE_ALLOC (resolved_type, + resolved_type->num_fields () * sizeof (struct field))); memcpy (TYPE_FIELDS (resolved_type), TYPE_FIELDS (type), resolved_type->num_fields () * sizeof (struct field)); @@ -2404,10 +2404,11 @@ compute_variant_fields (struct type *type, resolved_type->set_num_fields (std::count (flags.begin (), flags.end (), true)); - TYPE_FIELDS (resolved_type) - = (struct field *) TYPE_ALLOC (resolved_type, - resolved_type->num_fields () - * sizeof (struct field)); + resolved_type->set_fields + ((struct field *) + TYPE_ALLOC (resolved_type, + resolved_type->num_fields () * sizeof (struct field))); + int out = 0; for (int i = 0; i < type->num_fields (); ++i) { @@ -2448,10 +2449,10 @@ resolve_dynamic_struct (struct type *type, } else { - TYPE_FIELDS (resolved_type) - = (struct field *) TYPE_ALLOC (resolved_type, - resolved_type->num_fields () - * sizeof (struct field)); + resolved_type->set_fields + ((struct field *) + TYPE_ALLOC (resolved_type, + resolved_type->num_fields () * sizeof (struct field))); memcpy (TYPE_FIELDS (resolved_type), TYPE_FIELDS (type), resolved_type->num_fields () * sizeof (struct field)); @@ -5301,8 +5302,10 @@ copy_type_recursive (struct objfile *objfile, int i, nfields; nfields = type->num_fields (); - TYPE_FIELDS (new_type) = (struct field *) - TYPE_ZALLOC (new_type, nfields * sizeof (struct field)); + new_type->set_fields + ((struct field *) + TYPE_ZALLOC (new_type, nfields * sizeof (struct field))); + for (i = 0; i < nfields; i++) { TYPE_FIELD_ARTIFICIAL (new_type, i) = @@ -5560,8 +5563,8 @@ arch_flags_type (struct gdbarch *gdbarch, const char *name, int bit) TYPE_UNSIGNED (type) = 1; type->set_num_fields (0); /* Pre-allocate enough space assuming every field is one bit. */ - TYPE_FIELDS (type) - = (struct field *) TYPE_ZALLOC (type, bit * sizeof (struct field)); + type->set_fields + ((struct field *) TYPE_ZALLOC (type, bit * sizeof (struct field))); return type; } @@ -5631,8 +5634,8 @@ append_composite_type_field_raw (struct type *t, const char *name, struct field *f; t->set_num_fields (t->num_fields () + 1); - TYPE_FIELDS (t) = XRESIZEVEC (struct field, TYPE_FIELDS (t), - t->num_fields ()); + t->set_fields (XRESIZEVEC (struct field, TYPE_FIELDS (t), + t->num_fields ())); f = &(TYPE_FIELDS (t)[t->num_fields () - 1]); memset (f, 0, sizeof f[0]); FIELD_TYPE (f[0]) = field; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index e5f46dca0d..3ed9f8e7fc 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -913,6 +913,18 @@ struct type this->main_type->nfields = num_fields; } + /* Get the fields array of this type. */ + field *fields () const + { + return this->main_type->flds_bnds.fields; + } + + /* Set the fields array of this type. */ + void set_fields (field *fields) + { + this->main_type->flds_bnds.fields = fields; + } + /* * Return the dynamic property of the requested KIND from this type's list of dynamic properties. */ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; @@ -1458,7 +1470,7 @@ extern unsigned type_align (struct type *); space in struct type. */ extern bool set_type_align (struct type *, ULONGEST); -#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields +#define TYPE_FIELDS(thistype) (thistype)->fields () #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0) #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index c1967e62bb..064f924c76 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -166,7 +166,7 @@ build_gdb_vtable_type (struct gdbarch *arch) t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); t->set_num_fields (field - field_list); - TYPE_FIELDS (t) = field_list; + t->set_fields (field_list); t->set_name ("gdb_gnu_v3_abi_vtable"); INIT_CPLUS_SPECIFIC (t); @@ -1055,7 +1055,7 @@ build_std_type_info_type (struct gdbarch *arch) t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); t->set_num_fields (field - field_list); - TYPE_FIELDS (t) = field_list; + t->set_fields (field_list); t->set_name ("gdb_gnu_v3_type_info"); INIT_CPLUS_SPECIFIC (t); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index f634dbb08f..aeecb14f19 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1018,9 +1018,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, t->set_code (type_code); TYPE_LENGTH (t) = sh->value; t->set_num_fields (nfields); - TYPE_FIELDS (t) = f = ((struct field *) - TYPE_ALLOC (t, - nfields * sizeof (struct field))); + f = ((struct field *) TYPE_ALLOC (t, nfields * sizeof (struct field))); + t->set_fields (f); if (type_code == TYPE_CODE_ENUM) { @@ -1187,8 +1186,9 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, struct block_iterator iter; ftype->set_num_fields (nparams); - TYPE_FIELDS (ftype) = (struct field *) - TYPE_ALLOC (ftype, nparams * sizeof (struct field)); + ftype->set_fields + ((struct field *) + TYPE_ALLOC (ftype, nparams * sizeof (struct field))); iparams = 0; ALL_BLOCK_SYMBOLS (cblock, iter, sym) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f869662847..f7eba1d9f2 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -985,8 +985,8 @@ rust_composite_type (struct type *original, result->set_name (name); result->set_num_fields (nfields); - TYPE_FIELDS (result) - = (struct field *) TYPE_ZALLOC (result, nfields * sizeof (struct field)); + result->set_fields + ((struct field *) TYPE_ZALLOC (result, nfields * sizeof (struct field))); i = 0; bitpos = 0; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index daf88c851c..e710a43b7a 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -986,8 +986,9 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, } /* Allocate parameter information fields and fill them in. */ - TYPE_FIELDS (ftype) = (struct field *) - TYPE_ALLOC (ftype, nsemi * sizeof (struct field)); + ftype->set_fields + ((struct field *) + TYPE_ALLOC (ftype, nsemi * sizeof (struct field))); while (*p++ == ';') { struct type *ptype; @@ -1836,9 +1837,9 @@ again: && arg_types->type->code () == TYPE_CODE_VOID) num_args = 0; - TYPE_FIELDS (func_type) - = (struct field *) TYPE_ALLOC (func_type, - num_args * sizeof (struct field)); + func_type->set_fields + ((struct field *) TYPE_ALLOC (func_type, + num_args * sizeof (struct field))); memset (TYPE_FIELDS (func_type), 0, num_args * sizeof (struct field)); { int i; @@ -3309,8 +3310,9 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type, array of fields, and create blank visibility bitfields if necessary. */ type->set_num_fields (nfields); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, sizeof (struct field) * nfields); + type->set_fields + ((struct field *) + TYPE_ALLOC (type, sizeof (struct field) * nfields)); memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields); if (non_public_fields) @@ -3655,8 +3657,9 @@ read_enum_type (const char **pp, struct type *type, if (unsigned_enum) TYPE_UNSIGNED (type) = 1; type->set_num_fields (nsyms); - TYPE_FIELDS (type) = (struct field *) - TYPE_ALLOC (type, sizeof (struct field) * nsyms); + type->set_fields + ((struct field *) + TYPE_ALLOC (type, sizeof (struct field) * nsyms)); memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms); /* Find the symbols for the values and put them into the type. diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index d7c498f2e9..6eec2577f3 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -752,8 +752,8 @@ create_enum (struct gdbarch *gdbarch, int bit, const char *name, type = arch_type (gdbarch, TYPE_CODE_ENUM, bit, name); type->set_num_fields (count); - TYPE_FIELDS (type) = (struct field *) - TYPE_ZALLOC (type, sizeof (struct field) * count); + type->set_fields + ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * count)); TYPE_UNSIGNED (type) = 1; for (i = 0; i < count; i++) -- 2.34.1