-
Notifications
You must be signed in to change notification settings - Fork 277
Well formedness checking goto #3188
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ SRC += analyses/ai/ai.cpp \ | |
analyses/does_remove_const/does_type_preserve_const_correctness.cpp \ | ||
analyses/does_remove_const/is_type_at_least_as_const_as.cpp \ | ||
compound_block_locations.cpp \ | ||
goto-programs/goto_program_assume.cpp \ | ||
goto-programs/goto_program_dead.cpp \ | ||
goto-programs/goto_program_declaration.cpp \ | ||
goto-programs/goto_program_function_call.cpp \ | ||
goto-programs/goto_program_goto_target.cpp \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lexicographic ordering, please. (goto_program*<goto_trace_output) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tautschnig I fixed the ordering. As to the above |
||
goto-programs/goto_trace_output.cpp \ | ||
goto-symex/ssa_equation.cpp \ | ||
interpreter/interpreter.cpp \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Unit tests for goto_program::validate | ||
|
||
Author: Diffblue Ltd. | ||
|
||
\*******************************************************************/ | ||
|
||
#include <goto-programs/goto_function.h> | ||
#include <testing-utils/catch.hpp> | ||
#include <util/arith_tools.h> | ||
|
||
SCENARIO( | ||
"Validation of well-formed assert/assume codes", | ||
"[core][goto-programs][validate]") | ||
{ | ||
GIVEN("A program with one assumption") | ||
{ | ||
symbol_tablet symbol_table; | ||
const typet type1 = signedbv_typet(32); | ||
symbolt symbol; | ||
irep_idt symbol_name = "a"; | ||
symbol.name = symbol_name; | ||
symbol_exprt varx(symbol_name, type1); | ||
exprt val10 = from_integer(10, type1); | ||
binary_relation_exprt x_le_10(varx, ID_le, val10); | ||
|
||
goto_functiont goto_function; | ||
auto &instructions = goto_function.body.instructions; | ||
instructions.emplace_back(goto_program_instruction_typet::ASSUME); | ||
|
||
symbol.type = type1; | ||
symbol_table.insert(symbol); | ||
namespacet ns(symbol_table); | ||
instructions.back().make_assertion(x_le_10); | ||
|
||
WHEN("Instruction has no targets") | ||
{ | ||
THEN("The consistency check succeeds") | ||
{ | ||
goto_function.body.validate(ns, validation_modet::INVARIANT); | ||
REQUIRE(true); | ||
} | ||
} | ||
|
||
WHEN("Instruction has a target") | ||
{ | ||
instructions.back().targets.push_back(instructions.begin()); | ||
THEN("The consistency check fails") | ||
{ | ||
bool caught = false; | ||
try | ||
{ | ||
goto_function.body.validate(ns, validation_modet::EXCEPTION); | ||
} | ||
catch(incorrect_goto_program_exceptiont &e) | ||
{ | ||
caught = true; | ||
} | ||
REQUIRE(caught); | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.