Skip to content

Commit 35905c6

Browse files
Add can_cast_type, validate_type for pointer_typet
1 parent b72bacf commit 35905c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/util/std_types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include "expr.h"
2121
#include "mp_arith.h"
2222
#include "invariant.h"
23+
#include "expr_cast.h"
2324

2425
class constant_exprt;
2526

@@ -1430,6 +1431,18 @@ inline pointer_typet &to_pointer_type(typet &type)
14301431
return static_cast<pointer_typet &>(type);
14311432
}
14321433

1434+
template <>
1435+
inline bool can_cast_type<pointer_typet>(const typet &type)
1436+
{
1437+
return type.id() == ID_pointer;
1438+
}
1439+
1440+
inline void validate_type(const pointer_typet &type)
1441+
{
1442+
DATA_INVARIANT(!type.get(ID_width).empty(), "pointer must have width");
1443+
DATA_INVARIANT(type.get_width() > 0, "pointer must have non-zero width");
1444+
}
1445+
14331446
/*! \brief The reference type
14341447
*/
14351448
class reference_typet:public pointer_typet

0 commit comments

Comments
 (0)