+2020-11-11 Luis Machado <luis.machado@arm.com>
+
+ * valops.c (value_cast): Handle casting from capabilities and
+ capability pointers.
+
2020-11-11 Luis Machado <luis.machado@arm.com>
* aarch64-tdep.c (aarch64_address_class_type_flags)
|| code2 == TYPE_CODE_DECFLOAT || code2 == TYPE_CODE_ENUM
|| code2 == TYPE_CODE_RANGE);
- /* Handle casting capabilities to other scalar types. For now we truncate
- the capability value to the size of the target type. */
- if (scalar && code2 == TYPE_CODE_CAPABILITY)
+ int to_scalar = (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_FLT
+ || code1 == TYPE_CODE_DECFLOAT || code1 == TYPE_CODE_ENUM
+ || code1 == TYPE_CODE_RANGE);
+
+ /* Handle casting capabilities/capability pointers to other scalar types.
+ For now we truncate the capability value to the size of the target
+ type. */
+ if (to_scalar && (code2 == TYPE_CODE_CAPABILITY
+ || (code2 == TYPE_CODE_PTR && TYPE_CAPABILITY (type2))))
{
if (type->is_unsigned ())
- value_from_ulongest (to_type, value_as_long (arg2));
+ return value_from_ulongest (to_type, value_as_long (arg2));
else
- value_from_longest (to_type, value_as_long (arg2));
+ return value_from_longest (to_type, value_as_long (arg2));
}
if ((code1 == TYPE_CODE_STRUCT || code1 == TYPE_CODE_UNION)