Skip to content

change type of numerical architecture symbols to integer #7215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified regression/ansi-c/arch_flags_mcpu_bad/object.intel
Binary file not shown.
Binary file modified regression/ansi-c/arch_flags_mcpu_good/object.arm
Binary file not shown.
Binary file modified regression/ansi-c/arch_flags_mthumb_bad/object.intel
Binary file not shown.
Binary file modified regression/ansi-c/arch_flags_mthumb_good/object.arm
Binary file not shown.
3 changes: 2 additions & 1 deletion src/ansi-c/ansi_c_internal_additions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ static std::string architecture_string(const std::string &value, const char *s)
template <typename T>
static std::string architecture_string(T value, const char *s)
{
return std::string("const int " CPROVER_PREFIX "architecture_") +
return std::string("const " CPROVER_PREFIX "integer " CPROVER_PREFIX
"architecture_") +
std::string(s) + "=" + std::to_string(value) + ";\n";
}

Expand Down
28 changes: 26 additions & 2 deletions src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,12 +1451,36 @@ bool cpp_typecheckt::implicit_conversion_sequence(
{
rank=backup_rank;
if(!user_defined_conversion_sequence(e, type, new_expr, rank))
{
if(
type.id() == ID_integer &&
(expr.type().id() == ID_signedbv || expr.type().id() == ID_unsignedbv))
{
// This is a nonstandard implicit conversion, from
// bit-vectors to unbounded integers.
rank = 0;
new_expr = typecast_exprt(expr, type);
return true;
}
else if(
(type.id() == ID_signedbv || type.id() == ID_unsignedbv) &&
expr.type().id() == ID_integer)
{
// This is a nonstandard implicit conversion, from
// unbounded integers to bit-vectors.
rank = 0;
new_expr = typecast_exprt(expr, type);
return true;
}

// no conversion
return false;
}

#if 0
#if 0
simplify_exprt simplify(*this);
simplify.simplify(new_expr);
#endif
#endif
}

return true;
Expand Down
15 changes: 15 additions & 0 deletions src/cpp/cpp_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Author: Daniel Kroening, [email protected]
/// C++ Language Type Checking

#include <util/c_types.h>
#include <util/cprover_prefix.h>
#include <util/mathematical_types.h>
#include <util/simplify_expr.h>
#include <util/source_location.h>

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

// CPROVER extensions
irep_idt typedef_identifier = type.get(ID_C_typedef);
if(typedef_identifier == CPROVER_PREFIX "rational")
{
type = rational_typet();
type.add_source_location() = symbol_expr.source_location();
}
else if(typedef_identifier == CPROVER_PREFIX "integer")
{
type = integer_typet();
type.add_source_location() = symbol_expr.source_location();
}

qualifiers.write(type);
}
else if(type.id()==ID_struct ||
Expand Down
2 changes: 1 addition & 1 deletion src/util/interval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ bool constant_interval_exprt::is_numeric(

bool constant_interval_exprt::is_int(const typet &type)
{
return (is_signed(type) || is_unsigned(type));
return is_signed(type) || is_unsigned(type) || type.id() == ID_integer;
}

bool constant_interval_exprt::is_float(const typet &src)
Expand Down