Fixed #6629: Don't simplify sinf(0) if sinf is a variable

This commit is contained in:
PKEuS 2015-04-13 20:37:07 +02:00
parent 708a379fd2
commit c4ceb97cea
2 changed files with 6 additions and 1 deletions

View File

@ -8372,7 +8372,7 @@ bool Tokenizer::isTwoNumber(const std::string &s)
void Tokenizer::simplifyMathFunctions()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->isName() && tok->strAt(1) == "(") { // precondition for function
if (tok->isName() && !tok->varId() && tok->strAt(1) == "(") { // precondition for function
bool simplifcationMade = false;
if (Token::Match(tok, "atol ( %str% )")) { //@todo Add support for atoll()
if (tok->previous() &&

View File

@ -7557,6 +7557,11 @@ private:
"std :: cout << 0 ;\n"
"}";
ASSERT_EQUALS(expected_sinl, tokenizeAndStringify(code_sinl));
// #6629
const char code[] = "class Foo { int sinf; Foo() : sinf(0) {} };";
const char expected[] = "class Foo { int sinf ; Foo ( ) : sinf ( 0 ) { } } ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
void simplifyMathFunctions_ilogb() {