result_type->set_bounds (bounds);
+ /* Note that the signed-ness of a range type can't simply be copied
+ from the underlying type. Consider a case where the underlying
+ type is 'int', but the range type can hold 0..65535, and where
+ the range is further specified to fit into 16 bits. In this
+ case, if we copy the underlying type's sign, then reading some
+ range values will cause an unwanted sign extension. So, we have
+ some heuristics here instead. */
if (low_bound->kind () == PROP_CONST && low_bound->const_val () >= 0)
result_type->set_is_unsigned (true);
-
/* Ada allows the declaration of range types whose upper bound is
less than the lower bound, so checking the lower bound is not
enough. Make sure we do not mark a range type whose upper bound
if (unsigned_p)
t->set_is_unsigned (true);
+ TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
+ TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
+ TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+
return t;
}
if (unsigned_p)
t->set_is_unsigned (true);
+ TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
+ TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
+ TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+
return t;
}
if (TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type == nullptr)
{
- if (name == nullptr)
+ if (name == nullptr && target_type->name () != nullptr)
{
char *new_name
= (char *) TYPE_ALLOC (target_type,
gdb_print_host_address (TYPE_SELF_TYPE (type), gdb_stdout);
puts_filtered ("\n");
break;
+
+ case TYPE_SPECIFIC_INT:
+ if (type->bit_size_differs_p ())
+ {
+ unsigned bit_size = type->bit_size ();
+ unsigned bit_off = type->bit_offset ();
+ printfi_filtered (spaces, " bit size = %u, bit offset = %u\n",
+ bit_size, bit_off);
+ }
+ break;
}
if (spaces == 0)
types without duplicates. We use OBJFILE's obstack, because
OBJFILE is about to be deleted. */
-htab_t
+htab_up
create_copied_types_hash (struct objfile *objfile)
{
- return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
- NULL, &objfile->objfile_obstack,
- hashtab_obstack_allocate,
- dummy_obstack_deallocate);
+ return htab_up (htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
+ NULL, &objfile->objfile_obstack,
+ hashtab_obstack_allocate,
+ dummy_obstack_deallocate));
}
/* Recursively copy (deep copy) a dynamic attribute list of a type. */
copy_type_recursive (objfile, TYPE_SELF_TYPE (type),
copied_types));
break;
+ case TYPE_SPECIFIC_INT:
+ TYPE_SPECIFIC_FIELD (new_type) = TYPE_SPECIFIC_INT;
+ TYPE_MAIN_TYPE (new_type)->type_specific.int_stuff
+ = TYPE_MAIN_TYPE (type)->type_specific.int_stuff;
+ break;
+
default:
gdb_assert_not_reached ("bad type_specific_kind");
}