Skip to content

Commit 85a81ea

Browse files
author
Thomas Kiley
authored
Merge pull request #2594 from thk123/array_type_check
Introduce can_cast_type for array_typet
2 parents 2becafd + d42821f commit 85a81ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/util/std_types.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,12 @@ class array_typet:public type_with_subtypet
10411041
}
10421042
};
10431043

1044+
template <>
1045+
inline bool can_cast_type<array_typet>(const typet &type)
1046+
{
1047+
return type.id() == ID_array;
1048+
}
1049+
10441050
/*! \brief Cast a generic typet to an \ref array_typet
10451051
*
10461052
* This is an unchecked conversion. \a type must be known to be \ref
@@ -1053,7 +1059,7 @@ class array_typet:public type_with_subtypet
10531059
*/
10541060
inline const array_typet &to_array_type(const typet &type)
10551061
{
1056-
PRECONDITION(type.id()==ID_array);
1062+
PRECONDITION(can_cast_type<array_typet>(type));
10571063
return static_cast<const array_typet &>(type);
10581064
}
10591065

@@ -1062,7 +1068,7 @@ inline const array_typet &to_array_type(const typet &type)
10621068
*/
10631069
inline array_typet &to_array_type(typet &type)
10641070
{
1065-
PRECONDITION(type.id()==ID_array);
1071+
PRECONDITION(can_cast_type<array_typet>(type));
10661072
return static_cast<array_typet &>(type);
10671073
}
10681074

0 commit comments

Comments
 (0)