unsigned resolved_type_bit_length = 0;
gdb_assert (type->code () == TYPE_CODE_STRUCT);
- gdb_assert (type->num_fields () > 0);
resolved_type = copy_type (type);
((struct field *)
TYPE_ALLOC (resolved_type,
resolved_type->num_fields () * sizeof (struct field)));
- memcpy (resolved_type->fields (),
- type->fields (),
- resolved_type->num_fields () * sizeof (struct field));
+ if (type->num_fields () > 0)
+ memcpy (resolved_type->fields (),
+ type->fields (),
+ resolved_type->num_fields () * sizeof (struct field));
}
for (i = 0; i < resolved_type->num_fields (); ++i)
return t;
}
+/* Return true if init_complex_type can be called with TARGET_TYPE. */
+
+bool
+can_create_complex_type (struct type *target_type)
+{
+ return (target_type->code () == TYPE_CODE_INT
+ || target_type->code () == TYPE_CODE_FLT);
+}
+
/* Allocate a TYPE_CODE_COMPLEX type structure. NAME is the type
name. TARGET_TYPE is the component type. */
{
struct type *t;
- gdb_assert (target_type->code () == TYPE_CODE_INT
- || target_type->code () == TYPE_CODE_FLT);
+ gdb_assert (can_create_complex_type (target_type));
if (TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type == nullptr)
{
if (b->code () == TYPE_CODE_TYPEDEF)
b = check_typedef (b);
+ /* Check if identical after resolving typedefs. */
+ if (a == b)
+ return true;
+
/* If after resolving typedefs a and b are not of the same type
code then they are not equal. */
if (a->code () != b->code ())
&& strcmp (a->name (), b->name ()) == 0)
return true;
- /* Check if identical after resolving typedefs. */
- if (a == b)
- return true;
-
/* Two function types are equal if their argument and return types
are equal. */
if (a->code () == TYPE_CODE_FUNC)
case TYPE_CODE_CHAR:
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
- if (TYPE_DECLARED_CLASS (arg))
+ if (arg->is_declared_class ())
return INCOMPATIBLE_TYPE_BADNESS;
return INTEGER_PROMOTION_BADNESS;
case TYPE_CODE_FLT:
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
case TYPE_CODE_ENUM:
- if (TYPE_DECLARED_CLASS (parm) || TYPE_DECLARED_CLASS (arg))
+ if (parm->is_declared_class () || arg->is_declared_class ())
return INCOMPATIBLE_TYPE_BADNESS;
return INTEGER_CONVERSION_BADNESS;
case TYPE_CODE_FLT:
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
case TYPE_CODE_ENUM:
- if (TYPE_DECLARED_CLASS (arg))
+ if (arg->is_declared_class ())
return INCOMPATIBLE_TYPE_BADNESS;
return INTEGER_CONVERSION_BADNESS;
case TYPE_CODE_FLT:
return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL),
REFERENCE_SEE_THROUGH_BADNESS));
if (overload_debug)
- /* Debugging only. */
- fprintf_filtered (gdb_stderr,
- "------ Arg is %s [%d], parm is %s [%d]\n",
- arg->name (), arg->code (),
- parm->name (), parm->code ());
+ {
+ /* Debugging only. */
+ fprintf_filtered (gdb_stderr,
+ "------ Arg is %s [%d], parm is %s [%d]\n",
+ arg->name (), arg->code (),
+ parm->name (), parm->code ());
+ }
/* x -> y means arg of type x being supplied for parameter of type y. */
builtin_type->builtin_string
= arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
builtin_type->builtin_bool
- = arch_type (gdbarch, TYPE_CODE_BOOL, TARGET_CHAR_BIT, "bool");
+ = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool");
/* The following three are about decimal floating point types, which
are 32-bits, 64-bits and 128-bits respectively. */