File tree 5 files changed +38
-9
lines changed
contracts/function_check_02 5 files changed +38
-9
lines changed Original file line number Diff line number Diff line change
1
+ // clang-format off
2
+ int foo ()
3
+ __CPROVER_ensures (__CPROVER_forall {int i ; 1 == 1 })
4
+ // clang-format on
5
+ {
6
+ return 1 ;
7
+ }
8
+
9
+ // clang-format off
10
+ int bar ()
11
+ __CPROVER_ensures (__CPROVER_forall {int i ; 1 == 1 } &&
12
+ __CPROVER_return_value == 1 )
13
+ // clang-format on
14
+ {
15
+ return 1 ;
16
+ }
17
+
18
+ int main ()
19
+ {
20
+ foo ();
21
+ bar ();
22
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^warning: ignoring
8
+ ^CONVERSION ERROR$
Original file line number Diff line number Diff line change 1
1
// function_check_02
2
2
3
3
// This test checks the use of quantifiers in ensures clauses.
4
- // A known bug (resolved in PR #2278) causes the use of quantifiers
5
- // in ensures to fail.
6
4
7
5
int initialize (int * arr )
8
6
__CPROVER_ensures (
Original file line number Diff line number Diff line change 1
- KNOWNBUG
1
+ CORE
2
2
main.c
3
- --check -code-contracts
3
+ --apply -code-contracts
4
4
^EXIT=0$
5
5
^SIGNAL=0$
6
6
^VERIFICATION SUCCESSFUL$
7
7
--
8
- --
9
- Ensures statements currently do not allow quantified predicates unless the
10
- function has void return type.
Original file line number Diff line number Diff line change @@ -748,11 +748,15 @@ void c_typecheck_baset::typecheck_declaration(
748
748
typet ret_type = void_type ();
749
749
if (new_symbol.type .id ()==ID_code)
750
750
ret_type=to_code_type (new_symbol.type ).return_type ();
751
- assert (parameter_map.empty ());
752
751
if (ret_type.id ()!=ID_empty)
752
+ {
753
+ DATA_INVARIANT (
754
+ parameter_map.empty (), " parameter map should be cleared" );
753
755
parameter_map[CPROVER_PREFIX " return_value" ] = ret_type;
756
+ }
754
757
typecheck_spec_expr (static_cast <codet &>(contract), ID_C_spec_ensures);
755
- parameter_map.clear ();
758
+ if (ret_type.id () != ID_empty)
759
+ parameter_map.clear ();
756
760
757
761
irept assigns_to_add = contract.find (ID_C_spec_assigns);
758
762
if (assigns_to_add.is_not_nil ())
You can’t perform that action at this time.
0 commit comments