}
TYPE_NFIELDS (fn) = nparams;
- TYPE_FIELDS (fn) = TYPE_ZALLOC (fn, nparams * sizeof (struct field));
+ TYPE_FIELDS (fn)
+ = (struct field *) TYPE_ZALLOC (fn, nparams * sizeof (struct field));
for (i = 0; i < nparams; ++i)
TYPE_FIELD_TYPE (fn, i) = param_types[i];
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;
- if (has_static_range (TYPE_RANGE_DATA (range_type)))
+ if (has_static_range (TYPE_RANGE_DATA (range_type))
+ && (!type_not_associated (result_type)
+ && !type_not_allocated (result_type)))
{
LONGEST low_bound, high_bound;
TYPE_CODE (result_type) = TYPE_CODE_SET;
TYPE_NFIELDS (result_type) = 1;
- TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type, sizeof (struct field));
+ TYPE_FIELDS (result_type)
+ = (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
if (!TYPE_STUB (domain_type))
{
lookup_unsigned_typename (const struct language_defn *language,
struct gdbarch *gdbarch, const char *name)
{
- char *uns = alloca (strlen (name) + 10);
+ char *uns = (char *) alloca (strlen (name) + 10);
strcpy (uns, "unsigned ");
strcpy (uns + 9, name);
struct gdbarch *gdbarch, const char *name)
{
struct type *t;
- char *uns = alloca (strlen (name) + 8);
+ char *uns = (char *) alloca (strlen (name) + 8);
strcpy (uns, "signed ");
strcpy (uns + 7, name);
|| TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
return 1;
+ if (TYPE_ASSOCIATED_PROP (type))
+ return 1;
+
+ if (TYPE_ALLOCATED_PROP (type))
+ return 1;
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_RANGE:
struct type *elt_type;
struct type *range_type;
struct type *ary_dim;
+ struct dynamic_prop *prop;
gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
+ type = copy_type (type);
+
elt_type = type;
range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
range_type = resolve_dynamic_range (range_type, addr_stack);
+ /* Resolve allocated/associated here before creating a new array type, which
+ will update the length of the array accordingly. */
+ prop = TYPE_ALLOCATED_PROP (type);
+ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
+ {
+ TYPE_DYN_PROP_ADDR (prop) = value;
+ TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
+ }
+ prop = TYPE_ASSOCIATED_PROP (type);
+ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
+ {
+ TYPE_DYN_PROP_ADDR (prop) = value;
+ TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
+ }
+
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
else
elt_type = TYPE_TARGET_TYPE (type);
- return create_array_type_with_stride (copy_type (type),
- elt_type, range_type,
- TYPE_FIELD_BITSIZE (type, 0));
+ return create_array_type_with_stride (type, elt_type, range_type,
+ TYPE_FIELD_BITSIZE (type, 0));
}
/* Resolve dynamic bounds of members of the union TYPE to static
resolved_type = copy_type (type);
TYPE_FIELDS (resolved_type)
- = TYPE_ALLOC (resolved_type,
- TYPE_NFIELDS (resolved_type) * sizeof (struct field));
+ = (struct field *) TYPE_ALLOC (resolved_type,
+ TYPE_NFIELDS (resolved_type)
+ * sizeof (struct field));
memcpy (TYPE_FIELDS (resolved_type),
TYPE_FIELDS (type),
TYPE_NFIELDS (resolved_type) * sizeof (struct field));
resolved_type = copy_type (type);
TYPE_FIELDS (resolved_type)
- = TYPE_ALLOC (resolved_type,
- TYPE_NFIELDS (resolved_type) * sizeof (struct field));
+ = (struct field *) TYPE_ALLOC (resolved_type,
+ TYPE_NFIELDS (resolved_type)
+ * sizeof (struct field));
memcpy (TYPE_FIELDS (resolved_type),
TYPE_FIELDS (type),
TYPE_NFIELDS (resolved_type) * sizeof (struct field));
gdb_assert (TYPE_OBJFILE_OWNED (type));
- temp = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct dynamic_prop_list));
+ temp = XOBNEW (&objfile->objfile_obstack, struct dynamic_prop_list);
temp->prop_kind = prop_kind;
temp->prop = prop;
temp->next = TYPE_DYN_PROP_LIST (type);
/* Return true if TYPE is scalar. */
-static int
+int
is_scalar_type (struct type *type)
{
type = check_typedef (type);
return result;
}
+
+/* Allocated status of type TYPE. Return zero if type TYPE is allocated.
+ Otherwise return one. */
+
+int
+type_not_allocated (const struct type *type)
+{
+ struct dynamic_prop *prop = TYPE_ALLOCATED_PROP (type);
+
+ return (prop && TYPE_DYN_PROP_KIND (prop) == PROP_CONST
+ && !TYPE_DYN_PROP_ADDR (prop));
+}
+
+/* Associated status of type TYPE. Return zero if type TYPE is associated.
+ Otherwise return one. */
+
+int
+type_not_associated (const struct type *type)
+{
+ struct dynamic_prop *prop = TYPE_ASSOCIATED_PROP (type);
+
+ return (prop && TYPE_DYN_PROP_KIND (prop) == PROP_CONST
+ && !TYPE_DYN_PROP_ADDR (prop));
+}
\f
/* Compare one type (PARM) for compatibility with another (ARG).
* PARM is intended to be the parameter type of a function; and
static hashval_t
type_pair_hash (const void *item)
{
- const struct type_pair *pair = item;
+ const struct type_pair *pair = (const struct type_pair *) item;
return htab_hash_pointer (pair->old);
}
static int
type_pair_eq (const void *item_lhs, const void *item_rhs)
{
- const struct type_pair *lhs = item_lhs, *rhs = item_rhs;
+ const struct type_pair *lhs = (const struct type_pair *) item_lhs;
+ const struct type_pair *rhs = (const struct type_pair *) item_rhs;
return lhs->old == rhs->old;
}
{
struct dynamic_prop_list *node_copy;
- node_copy = obstack_copy (objfile_obstack, *node_ptr,
- sizeof (struct dynamic_prop_list));
+ node_copy = ((struct dynamic_prop_list *)
+ obstack_copy (objfile_obstack, *node_ptr,
+ sizeof (struct dynamic_prop_list)));
node_copy->prop = (*node_ptr)->prop;
*node_ptr = node_copy;
}
/* Recursively copy (deep copy) TYPE, if it is associated with
- OBJFILE. Return a new type allocated using malloc, a saved type if
- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
- not associated with OBJFILE. */
+ OBJFILE. Return a new type owned by the gdbarch associated with the type, a
+ saved type if we have already visited TYPE (using COPIED_TYPES), or TYPE if
+ it is not associated with OBJFILE. */
struct type *
copy_type_recursive (struct objfile *objfile,
TYPE_LENGTH (type) = length;
if (name)
- TYPE_NAME (type) = xstrdup (name);
+ TYPE_NAME (type) = gdbarch_obstack_strdup (gdbarch, name);
return type;
}
type = arch_type (gdbarch, TYPE_CODE_FLAGS, length, name);
TYPE_UNSIGNED (type) = 1;
TYPE_NFIELDS (type) = nfields;
- TYPE_FIELDS (type) = TYPE_ZALLOC (type, nfields * sizeof (struct field));
+ TYPE_FIELDS (type)
+ = (struct field *) TYPE_ZALLOC (type, nfields * sizeof (struct field));
return type;
}
struct field *f;
TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
- TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t),
- sizeof (struct field) * TYPE_NFIELDS (t));
+ TYPE_FIELDS (t) = XRESIZEVEC (struct field, TYPE_FIELDS (t),
+ TYPE_NFIELDS (t));
f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
memset (f, 0, sizeof f[0]);
FIELD_TYPE (f[0]) = field;
const struct builtin_type *
builtin_type (struct gdbarch *gdbarch)
{
- return gdbarch_data (gdbarch, gdbtypes_data);
+ return (const struct builtin_type *) gdbarch_data (gdbarch, gdbtypes_data);
}
static void *
{
struct gdbarch *gdbarch;
struct objfile_type *objfile_type
- = objfile_data (objfile, objfile_type_data);
+ = (struct objfile_type *) objfile_data (objfile, objfile_type_data);
if (objfile_type)
return objfile_type;