Skip to content

Commit d9fee7c

Browse files
authored
Merge pull request #7215 from diffblue/architecture_integer
change type of numerical architecture symbols to integer
2 parents 8215674 + a4ffe59 commit d9fee7c

File tree

8 files changed

+44
-4
lines changed

8 files changed

+44
-4
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ static std::string architecture_string(const std::string &value, const char *s)
113113
template <typename T>
114114
static std::string architecture_string(T value, const char *s)
115115
{
116-
return std::string("const int " CPROVER_PREFIX "architecture_") +
116+
return std::string("const " CPROVER_PREFIX "integer " CPROVER_PREFIX
117+
"architecture_") +
117118
std::string(s) + "=" + std::to_string(value) + ";\n";
118119
}
119120

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,36 @@ bool cpp_typecheckt::implicit_conversion_sequence(
14511451
{
14521452
rank=backup_rank;
14531453
if(!user_defined_conversion_sequence(e, type, new_expr, rank))
1454+
{
1455+
if(
1456+
type.id() == ID_integer &&
1457+
(expr.type().id() == ID_signedbv || expr.type().id() == ID_unsignedbv))
1458+
{
1459+
// This is a nonstandard implicit conversion, from
1460+
// bit-vectors to unbounded integers.
1461+
rank = 0;
1462+
new_expr = typecast_exprt(expr, type);
1463+
return true;
1464+
}
1465+
else if(
1466+
(type.id() == ID_signedbv || type.id() == ID_unsignedbv) &&
1467+
expr.type().id() == ID_integer)
1468+
{
1469+
// This is a nonstandard implicit conversion, from
1470+
// unbounded integers to bit-vectors.
1471+
rank = 0;
1472+
new_expr = typecast_exprt(expr, type);
1473+
return true;
1474+
}
1475+
1476+
// no conversion
14541477
return false;
1478+
}
14551479

1456-
#if 0
1480+
#if 0
14571481
simplify_exprt simplify(*this);
14581482
simplify.simplify(new_expr);
1459-
#endif
1483+
#endif
14601484
}
14611485

14621486
return true;

src/cpp/cpp_typecheck_type.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Author: Daniel Kroening, [email protected]
1010
/// C++ Language Type Checking
1111

1212
#include <util/c_types.h>
13+
#include <util/cprover_prefix.h>
14+
#include <util/mathematical_types.h>
1315
#include <util/simplify_expr.h>
1416
#include <util/source_location.h>
1517

@@ -69,6 +71,19 @@ void cpp_typecheckt::typecheck_type(typet &type)
6971
if(type.get_bool(ID_C_constant))
7072
qualifiers.is_constant = true;
7173

74+
// CPROVER extensions
75+
irep_idt typedef_identifier = type.get(ID_C_typedef);
76+
if(typedef_identifier == CPROVER_PREFIX "rational")
77+
{
78+
type = rational_typet();
79+
type.add_source_location() = symbol_expr.source_location();
80+
}
81+
else if(typedef_identifier == CPROVER_PREFIX "integer")
82+
{
83+
type = integer_typet();
84+
type.add_source_location() = symbol_expr.source_location();
85+
}
86+
7287
qualifiers.write(type);
7388
}
7489
else if(type.id()==ID_struct ||

src/util/interval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ bool constant_interval_exprt::is_numeric(
10941094

10951095
bool constant_interval_exprt::is_int(const typet &type)
10961096
{
1097-
return (is_signed(type) || is_unsigned(type));
1097+
return is_signed(type) || is_unsigned(type) || type.id() == ID_integer;
10981098
}
10991099

11001100
bool constant_interval_exprt::is_float(const typet &src)

0 commit comments

Comments
 (0)