Skip to content

Commit f4f4190

Browse files
Added can_cast_type implementation for code_typet
1 parent 05bebb7 commit f4f4190

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/util/std_types.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,12 @@ class code_typet:public typet
974974
}
975975
};
976976

977+
template <>
978+
inline bool can_cast_type<code_typet>(const typet &type)
979+
{
980+
return type.id() == ID_code;
981+
}
982+
977983
/*! \brief Cast a generic typet to a \ref code_typet
978984
*
979985
* This is an unchecked conversion. \a type must be known to be \ref
@@ -986,7 +992,8 @@ class code_typet:public typet
986992
*/
987993
inline const code_typet &to_code_type(const typet &type)
988994
{
989-
PRECONDITION(type.id()==ID_code);
995+
PRECONDITION(can_cast_type<code_typet>(type));
996+
validate_type(type);
990997
return static_cast<const code_typet &>(type);
991998
}
992999

@@ -995,10 +1002,12 @@ inline const code_typet &to_code_type(const typet &type)
9951002
*/
9961003
inline code_typet &to_code_type(typet &type)
9971004
{
998-
PRECONDITION(type.id()==ID_code);
1005+
PRECONDITION(can_cast_type<code_typet>(type));
1006+
validate_type(type);
9991007
return static_cast<code_typet &>(type);
10001008
}
10011009

1010+
10021011
/*! \brief arrays with given size
10031012
*/
10041013
class array_typet:public type_with_subtypet

0 commit comments

Comments
 (0)