Fixed #6971 (False positive duplicateExpressionTernary - cast ignored)

This commit is contained in:
Daniel Marjamäki 2016-08-01 21:53:43 +02:00
parent 695b1f0ef3
commit e784901303
2 changed files with 11 additions and 1 deletions

View File

@ -178,7 +178,12 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2
if (tok1->str() == "(" && tok1->previous() && !tok1->previous()->isName()) { // cast => assert that the casts are equal
const Token *t1 = tok1->next();
const Token *t2 = tok2->next();
while (t1 && t2 && t1->str() == t2->str() && (t1->isName() || t1->str() == "*")) {
while (t1 && t2 &&
t1->str() == t2->str() &&
t1->isLong() == t2->isLong() &&
t1->isUnsigned() == t2->isUnsigned() &&
t1->isSigned() == t2->isSigned() &&
(t1->isName() || t1->str() == "*")) {
t1 = t1->next();
t2 = t2->next();
}

View File

@ -3815,6 +3815,11 @@ private:
" return A ? x : z;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void f(unsigned char c) {\n"
" x = y ? (signed char)c : (unsigned char)c;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void checkSignOfUnsignedVariable() {