parent
8cc7131ee9
commit
e1db4c0e2c
|
@ -1974,11 +1974,11 @@ void CheckOther::checkDuplicateExpression()
|
|||
}
|
||||
duplicateExpressionError(tok, tok, tok->str());
|
||||
}
|
||||
}
|
||||
} else if (styleEnabled &&
|
||||
isOppositeCond(true, _tokenizer->isCPP(), tok->astOperand1(), tok->astOperand2(), _settings->library, false) &&
|
||||
!Token::simpleMatch(tok, "=") &&
|
||||
isWithoutSideEffects(_tokenizer->isCPP(), tok->astOperand1())) {
|
||||
}
|
||||
} else if (styleEnabled &&
|
||||
isOppositeCond(true, _tokenizer->isCPP(), tok->astOperand1(), tok->astOperand2(), _settings->library, false) &&
|
||||
!Token::simpleMatch(tok, "=") &&
|
||||
isWithoutSideEffects(_tokenizer->isCPP(), tok->astOperand1())) {
|
||||
oppositeExpressionError(tok, tok, tok->str());
|
||||
} else if (!Token::Match(tok, "[-/%]")) { // These operators are not associative
|
||||
if (styleEnabled && tok->astOperand2() && tok->str() == tok->astOperand1()->str() && isSameExpression(_tokenizer->isCPP(), true, tok->astOperand2(), tok->astOperand1()->astOperand2(), _settings->library, true) && isWithoutSideEffects(_tokenizer->isCPP(), tok->astOperand2()))
|
||||
|
|
|
@ -947,13 +947,13 @@ private:
|
|||
}
|
||||
|
||||
void doublefree9() {
|
||||
check("struct foo {\n"
|
||||
" int* get(int) { return new int(); }\n"
|
||||
"};\n"
|
||||
"void f(foo* b) {\n"
|
||||
" std::unique_ptr<int> x(b->get(0));\n"
|
||||
" std::unique_ptr<int> y(b->get(1));\n"
|
||||
"}\n", true);
|
||||
check("struct foo {\n"
|
||||
" int* get(int) { return new int(); }\n"
|
||||
"};\n"
|
||||
"void f(foo* b) {\n"
|
||||
" std::unique_ptr<int> x(b->get(0));\n"
|
||||
" std::unique_ptr<int> y(b->get(1));\n"
|
||||
"}\n", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -3925,25 +3925,25 @@ private:
|
|||
|
||||
check("void f(bool a) { if(a != !a) {} }");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( a == !(a) ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '=='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( a != !(a) ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( !(a) == a ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '=='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( !(a) != a ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( !(!a) == !(a) ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '=='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { if( !(!a) != !(a) ) {}}");
|
||||
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Opposite expression on both sides of '!='.\n", errout.str());
|
||||
|
||||
|
||||
check("void f(bool a) { a = !a; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue