From 85fde23ce6374eaed501ade37e916433e8749bd5 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 25 Jun 2023 12:27:01 -0500 Subject: [PATCH] Fix 11505: FP zerodivcond with modulo --- lib/reverseanalyzer.cpp | 2 +- test/testother.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index d85366a7134..a243cc7eaa1 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -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 = diff --git a/test/testother.cpp b/test/testother.cpp index 0fa1c8c26f8..9082769aa9f 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {