Skip to content

Commit

Permalink
Fix overflow checking (#3353)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Jun 24, 2024
2 parents ab3a340 + fb3a5b1 commit 64126d9
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,18 @@ public ChoiceExpr visitOption_expr_paren(KeYParser.Option_expr_parenContext ctx)

@Override
public ChoiceExpr visitOption_expr_prop(KeYParser.Option_expr_propContext ctx) {
String category = ctx.option().cat.getText();
String value = ctx.option().value.getText();
String choiceStr = category + ":" + value;
/*
* Make sure that the choice (category and value!) is known to KeY, i.e. that it is declared
* in the file `optionsDeclarations.key`. This prevents from accidentally deactivating
* (parts of) taclets due to non-existing choices (see
* https://github.com/KeYProject/key/issues/3352).
*/
if (choices().lookup(choiceStr) == null) {
semanticError(ctx, "Could not find choice: %s", category + ":" + choiceStr);
}
return ChoiceExpr.variable(ctx.option().cat.getText(), ctx.option().value.getText());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public Taclet generateRelationalRepresentsTaclet(Name tacletName, Term originalA
new RewriteTacletGoalTemplate(addedSeq, ImmutableSLList.nil(), findTerm);

// choices, rule set
// Be careful that the choices used here is actually declared (see optionsDeclarations.key),
// otherwise the taclet will be unusable!
var choice = ChoiceExpr.variable("modelFields",
satisfiabilityGuard ? "showSatisfiability" : "treatAsAxiom");
final RuleSet ruleSet = new RuleSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
// --------------------------------------------------------------------------
// Axioms defining the integer translation functions
// --------------------------------------------------------------------------
\rules(programRules:Java, intRules:javaSemantics) {
\rules(programRules:Java & (intRules:javaSemantics | intRules:arithmeticSemanticsCheckingOF)) {
expandInByte {
\find(inByte(i))
\replacewith(inRangeByte(i))
Expand Down Expand Up @@ -149,7 +149,9 @@
\replacewith(inRangeLong(i))
\heuristics(concrete)
};
}

\rules(programRules:Java, intRules:javaSemantics) {
translateJavaUnaryMinusInt {
\find(javaUnaryMinusInt(left))
\replacewith(unaryMinusJint(left))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
\term numbers iz, jz;
}

\rules(programRules:Java & (intRules:arithmeticSemanticsIgnoringOF | intRules:arithmeticSemanticsCheckingOF)) {
\rules(programRules:Java & intRules:arithmeticSemanticsIgnoringOF) {

// ------------------------------------------------------------------------
// Rules to expand the predicates inByte, inShort, inInt, and inLong
Expand Down Expand Up @@ -50,6 +50,9 @@
\replacewith(true)
\heuristics(concrete)
};
}

\rules(programRules:Java & (intRules:arithmeticSemanticsIgnoringOF | intRules:arithmeticSemanticsCheckingOF)) {

// --------------------------------------------------------------------------
// Axioms defining the integer translation functions
Expand Down
Loading

0 comments on commit 64126d9

Please sign in to comment.