Skip to content

Commit

Permalink
Prevent warning on conditionals in SPARK code
Browse files Browse the repository at this point in the history
Ref. #312
  • Loading branch information
treiher committed Jul 1, 2020
1 parent 3fbddda commit 836a259
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions generated/rflx-ethernet.ads
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ is
pragma Warnings (On, "precondition is * false");

function Valid (Val : RFLX.Ethernet.TPID_Base) return Boolean is
(Val >= 16#8100#
and Val <= 16#8100#);
(Val = 16#8100#);

function To_Base (Val : RFLX.Ethernet.TPID) return RFLX.Ethernet.TPID_Base is
(RFLX.Ethernet.TPID_Base (Val));
Expand Down
3 changes: 1 addition & 2 deletions generated/rflx-ipv4.ads
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ is
pragma Warnings (On, "precondition is * false");

function Valid (Val : RFLX.IPv4.Version_Base) return Boolean is
(Val >= 4
and Val <= 4);
(Val = 4);

function To_Base (Val : RFLX.IPv4.Version) return RFLX.IPv4.Version_Base is
(RFLX.IPv4.Version_Base (Val));
Expand Down
3 changes: 3 additions & 0 deletions rflx/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def constraints(self, name: str, proof: bool = False) -> Sequence[Expr]:
Equal(Length(name), self.size, location=self.location),
]

if self.first.simplified() == self.last.simplified():
return [Equal(Variable(name), self.first)]

c: Expr = TRUE
if self.first.simplified() != self.base_first.simplified():
c = GreaterEqual(Variable(name), self.first)
Expand Down

0 comments on commit 836a259

Please sign in to comment.