Function pointers were not allowed to be cast to any integer like type
just like regular pointers were.
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::cast_rules): Authorize
cast from function pointer to integer like type.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
break;
case TyTy::TypeKind::REF:
+ case TyTy::TypeKind::FNPTR:
case TyTy::TypeKind::POINTER:
switch (to.get_ty ()->get_kind ())
{
case TyTy::TypeKind::INT:
{
// refs should not cast to numeric type
- bool from_ptr
- = from.get_ty ()->get_kind () == TyTy::TypeKind::POINTER;
+ auto kind = from.get_ty ()->get_kind ();
+ bool from_ptr = kind == TyTy::TypeKind::POINTER
+ || kind == TyTy::TypeKind::FNPTR;
if (from_ptr)
{
return TypeCoercionRules::CoercionResult{