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 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: illegal target in assigns clause$
6+ ^.*error: non-lvalue target in assigns clause$
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: void-typed targets not permitted$
6+ ^.*error: void-typed targets not permitted in assigns clause $
77--
88--
99Check 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 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: illegal target in assigns clause$
6+ ^.*error: non-lvalue target in assigns clause$
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: illegal target in assigns clause$
6+ ^.*error: non-lvalue target in assigns clause$
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: void-typed targets not permitted$
6+ ^.*error: void-typed targets not permitted in assigns clause $
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: illegal target in assigns clause$
6+ ^.*error: non-lvalue target in assigns clause$
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 33--enforce-contract foo
44^EXIT=(1|64)$
55^SIGNAL=0$
6- ^.*error: illegal target in assigns clause$
6+ ^.*error: non-lvalue target in assigns clause$
77^CONVERSION ERROR$
88--
99--
Original file line number Diff line number Diff line change 44^EXIT=(1|64)$
55^SIGNAL=0$
66^CONVERSION ERROR$
7- error: illegal target in assigns clause
7+ error: non-lvalue target in assigns clause
88--
99Checks 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(
739739 CPROVER_PREFIX " loop_entry is not allowed in preconditions." );
740740 }
741741
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 ());
769743
770744 if (!as_const (code_type).ensures ().empty ())
771745 {
Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ class c_typecheck_baset:
144144 virtual void typecheck_while (code_whilet &code);
145145 virtual void typecheck_dowhile (code_dowhilet &code);
146146 virtual void typecheck_start_thread (codet &code);
147+
148+ // contracts
149+ virtual void typecheck_spec_assigns (exprt::operandst &targets);
147150 virtual void typecheck_spec_loop_invariant (codet &code);
148151 virtual void typecheck_spec_decreases (codet &code);
149152
You can’t perform that action at this time.
0 commit comments