Fix 11505: FP zerodivcond with modulo (#5192)

This commit is contained in:
Paul Fultz II 2023-06-25 13:38:32 -05:00 committed by GitHub
parent 9b892f3239
commit 4f466a5961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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 =

View File

@ -820,6 +820,14 @@ private:
" 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() {