File tree Expand file tree Collapse file tree 13 files changed +84
-42
lines changed
assigns_enforce_address_of
assigns_enforce_function_calls
assigns_enforce_side_effects_1
assigns_enforce_side_effects_2
assigns_enforce_side_effects_3
assigns_type_checking_invalid_case_01 Expand file tree Collapse file tree 13 files changed +84
-42
lines changed Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: illegal target in assigns clause$
6
+ ^.*error: non-lvalue target in assigns clause$
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: void-typed targets not permitted$
6
+ ^.*error: void-typed targets not permitted in assigns clause $
7
7
--
8
8
--
9
9
Check that Elvis operator expressions '*(cond ? if_true : if_false)' with different types in true and false branches are rejected.
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: illegal target in assigns clause$
6
+ ^.*error: non-lvalue target in assigns clause$
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: illegal target in assigns clause$
6
+ ^.*error: non-lvalue target in assigns clause$
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: void-typed targets not permitted$
6
+ ^.*error: void-typed targets not permitted in assigns clause $
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: illegal target in assigns clause$
6
+ ^.*error: non-lvalue target in assigns clause$
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 3
3
--enforce-contract foo
4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
- ^.*error: illegal target in assigns clause$
6
+ ^.*error: non-lvalue target in assigns clause$
7
7
^CONVERSION ERROR$
8
8
--
9
9
--
Original file line number Diff line number Diff line change 4
4
^EXIT=(1|64)$
5
5
^SIGNAL=0$
6
6
^CONVERSION ERROR$
7
- error: illegal target in assigns clause
7
+ error: non-lvalue target in assigns clause
8
8
--
9
9
Checks whether type checking reports illegal target in assigns clause.
Original file line number Diff line number Diff line change @@ -739,33 +739,7 @@ void c_typecheck_baset::typecheck_declaration(
739
739
CPROVER_PREFIX " loop_entry is not allowed in preconditions." );
740
740
}
741
741
742
- for (auto &target : code_type.assigns ())
743
- {
744
- typecheck_expr (target);
745
-
746
- if (target.type ().id () == ID_empty)
747
- {
748
- error ().source_location = target.source_location ();
749
- error () << " void-typed targets not permitted" << eom;
750
- throw 0 ;
751
- }
752
- else if (target.id () == ID_pointer_object)
753
- {
754
- // skip
755
- }
756
- else if (!target.get_bool (ID_C_lvalue))
757
- {
758
- error ().source_location = target.source_location ();
759
- error () << " illegal target in assigns clause" << eom;
760
- throw 0 ;
761
- }
762
- else if (has_subexpr (target, ID_side_effect))
763
- {
764
- error ().source_location = target.source_location ();
765
- error () << " assigns clause is not side-effect free" << eom;
766
- throw 0 ;
767
- }
768
- }
742
+ typecheck_spec_assigns (code_type.assigns ());
769
743
770
744
if (!as_const (code_type).ensures ().empty ())
771
745
{
Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ class c_typecheck_baset:
144
144
virtual void typecheck_while (code_whilet &code);
145
145
virtual void typecheck_dowhile (code_dowhilet &code);
146
146
virtual void typecheck_start_thread (codet &code);
147
+
148
+ // contracts
149
+ virtual void typecheck_spec_assigns (exprt::operandst &targets);
147
150
virtual void typecheck_spec_loop_invariant (codet &code);
148
151
virtual void typecheck_spec_decreases (codet &code);
149
152
You can’t perform that action at this time.
0 commit comments