CheckCondition: Fix FP in daca (iqtree) 'in >> ch'

This commit is contained in:
Daniel Marjamäki 2017-09-13 22:46:36 +02:00
parent 8f6c98e3d6
commit bb20c0504e
2 changed files with 16 additions and 1 deletions

View File

@ -646,8 +646,13 @@ void CheckCondition::multiCondition2()
if (Token::Match(parent->astParent(), "%assign%"))
break;
}
if (Token::Match(tok, "%name% <<|>>") && (!tok->valueType() || !tok->valueType()->isIntegral()))
if (_tokenizer->isCPP() && Token::Match(tok, "%name% <<|>>") && (!tok->valueType() || !tok->valueType()->isIntegral()))
break;
if (_tokenizer->isCPP() && Token::simpleMatch(tok->previous(), ">>")) {
const Token *rhs = tok->previous()->astOperand1();
if (!rhs || !rhs->valueType() || !rhs->valueType()->isIntegral())
break;
}
if (Token::Match(tok, "%name% [")) {
const Token *tok2 = tok->linkAt(1);
while (Token::simpleMatch(tok2, "] ["))

View File

@ -1859,6 +1859,16 @@ private:
" if(++start<100 && 10<=section[start]) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
// daca iqtree
check("void readNCBITree(std::istream &in) {\n"
" char ch;\n"
" in >> ch;\n"
" if (ch != '|') return;\n"
" in >> ch;\n"
" if (ch != '|') {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// clarify conditions with = and comparison