From 3ff31b799c0fca95ffbe7358fe43fc483c8c9125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 30 Dec 2019 19:50:22 +0100 Subject: [PATCH] Verification: Use separate id for floating point division by zero --- lib/exprengine.cpp | 3 ++- test/testsuites/danmar-verify/divbyzero.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 0f43f331c..3f03f774e 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1734,7 +1734,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, if (tok->astParent()->astOperand2() == tok && value.isEqual(dataBase, 0)) { dataBase->addError(tok->linenr()); std::list callstack{tok->astParent()}; - ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, "verificationDivByZero", "There is division, cannot determine that there can't be a division by zero.", CWE(369), false); + const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "verificationDivByZeroFloat" : "verificationDivByZero"; + ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, id, "There is division, cannot determine that there can't be a division by zero.", CWE(369), false); errorLogger->reportErr(errmsg); } }; diff --git a/test/testsuites/danmar-verify/divbyzero.cpp b/test/testsuites/danmar-verify/divbyzero.cpp index d75b5a557..f7236ea7c 100644 --- a/test/testsuites/danmar-verify/divbyzero.cpp +++ b/test/testsuites/danmar-verify/divbyzero.cpp @@ -31,7 +31,7 @@ void float1(float f) { } void float2(float f) { - // cppcheck-suppress verificationDivByZero + // cppcheck-suppress verificationDivByZeroFloat return 100000 / f; }