|| code2 == TYPE_CODE_RANGE
|| is_fixed_point_type (type2));
- /* 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)