Skip to content

Commit

Permalink
Fix 11505: FP zerodivcond with modulo
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Jun 25, 2023
1 parent 9b892f3 commit 85fde23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reverseanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ struct ReverseTraversal {
continue;
}
// Simple assign
if (assignTok->astParent() == assignTop || assignTok == assignTop) {
if (assignTok->str() == "=" && (assignTok->astParent() == assignTop || assignTok == assignTop)) {
Analyzer::Action rhsAction =
analyzer->analyze(assignTok->astOperand2(), Analyzer::Direction::Reverse);
Analyzer::Action lhsAction =
Expand Down
8 changes: 8 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ class TestOther : public TestFixture {
" STATIC_ASSERT(sizeof(int) == sizeof(FOO));\n"
"}\n");
ASSERT_EQUALS("", errout.str());

// #11505
check("void f(uint16_t num, uint8_t radix) {\n"
" int c = num % radix;\n"
" num /= radix;\n"
" if (!num) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void nanInArithmeticExpression() {
Expand Down

0 comments on commit 85fde23

Please sign in to comment.