Add SIDEEFFECT warning on mishandled side effect cases (#487 partial)

This commit is contained in:
Wilson Snyder
2023-10-15 06:44:35 -04:00
parent 684aba0e90
commit c14eae6d56
13 changed files with 145 additions and 40 deletions
-20
View File
@@ -220,16 +220,6 @@ private:
}
void prepost_stmt_visit(AstNodeTriop* nodep) {
iterateChildren(nodep);
// Currently we can't reference the target, so we just copy the AST both for read and
// write, but doing so would double any side-effects, so as a safety measure all
// statements which could have side-effects are banned at the moment.
if (!nodep->rhsp()->isPure()) {
nodep->rhsp()->v3warn(E_UNSUPPORTED,
"Unsupported: Inc/Dec of expression with side-effects");
return;
}
AstConst* const constp = VN_AS(nodep->lhsp(), Const);
UASSERT_OBJ(nodep, constp, "Expecting CONST");
AstConst* const newconstp = constp->cloneTree(true);
@@ -250,16 +240,6 @@ private:
}
void prepost_expr_visit(AstNodeTriop* nodep) {
iterateChildren(nodep);
// Currently we can't reference the target, so we just copy the AST both for read and
// write, but doing so would double any side-effects, so as a safety measure all
// statements which could have side-effects are banned at the moment.
if (!nodep->rhsp()->isPure()) {
nodep->rhsp()->v3warn(E_UNSUPPORTED,
"Unsupported: Inc/Dec of expression with side-effects");
return;
}
if (m_unsupportedHere) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Incrementation in this context.");
return;