Fix ticket #317 (pre-increment causes style false positive)
This commit is contained in:
parent
7fdd497c44
commit
2d2c0e42cc
|
@ -2275,7 +2275,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
{
|
||||
incdec(value, tok3->strAt(1));
|
||||
tok2->tokAt(2)->str(value.c_str());
|
||||
if (Token::Match(tok3, "; %any% %any% ;"))
|
||||
if (Token::Match(tok3, "[;{}] %any% %any% ;"))
|
||||
{
|
||||
tok3->deleteNext();
|
||||
tok3->deleteNext();
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
TEST_CASE(declareVar);
|
||||
|
||||
TEST_CASE(removePostIncrement);
|
||||
TEST_CASE(removePreIncrement);
|
||||
|
||||
TEST_CASE(elseif1);
|
||||
|
||||
|
@ -394,6 +395,19 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void removePreIncrement()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" unsigned int c = 0;\n"
|
||||
" ++c;\n"
|
||||
" if (c>0) { ++c; }\n"
|
||||
" ++c;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(std::string("void f ( ) { int c ; c = 3 ; ; { ; } ; } "), tok(code));
|
||||
}
|
||||
|
||||
|
||||
std::string elseif(const char code[])
|
||||
{
|
||||
std::istringstream istr(code);
|
||||
|
|
Loading…
Reference in New Issue