don't print warning message if --enable=warning is not given.

message was of type:
(warning) Passing value 0 to foo() leads to implementation-defined result.
This commit is contained in:
Matthias Krüger 2015-04-06 13:37:27 +02:00
parent 592177200a
commit 988acf11b4
1 changed files with 43 additions and 40 deletions

View File

@ -1872,6 +1872,7 @@ void CheckOther::nanInArithmeticExpressionError(const Token *tok)
void CheckOther::checkMathFunctions() void CheckOther::checkMathFunctions()
{ {
bool styleC99 = _settings->isEnabled("style") && _settings->standards.c != Standards::C89 && _settings->standards.cpp != Standards::CPP03; bool styleC99 = _settings->isEnabled("style") && _settings->standards.c != Standards::C89 && _settings->standards.cpp != Standards::CPP03;
bool printWarnings = _settings->isEnabled("warning");
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
const std::size_t functions = symbolDatabase->functionScopes.size(); const std::size_t functions = symbolDatabase->functionScopes.size();
@ -1880,6 +1881,7 @@ void CheckOther::checkMathFunctions()
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (tok->varId()) if (tok->varId())
continue; continue;
if (printWarnings) {
if (tok->strAt(-1) != "." if (tok->strAt(-1) != "."
&& Token::Match(tok, "log|logf|logl|log10|log10f|log10l ( %num% )")) { && Token::Match(tok, "log|logf|logl|log10|log10f|log10l ( %num% )")) {
const std::string& number = tok->strAt(2); const std::string& number = tok->strAt(2);
@ -1923,6 +1925,7 @@ void CheckOther::checkMathFunctions()
if (MathLib::isNullValue(tok->strAt(2)) && MathLib::isNegative(tok->strAt(4))) if (MathLib::isNullValue(tok->strAt(2)) && MathLib::isNegative(tok->strAt(4)))
mathfunctionCallWarning(tok, 2); mathfunctionCallWarning(tok, 2);
} }
}
if (styleC99) { if (styleC99) {
if (Token::Match(tok, "%num% - erf (") && Tokenizer::isOneNumber(tok->str()) && tok->next()->astOperand2() == tok->tokAt(3)) { if (Token::Match(tok, "%num% - erf (") && Tokenizer::isOneNumber(tok->str()) && tok->next()->astOperand2() == tok->tokAt(3)) {