Variable usage: Fixed false positives (tmp1 ? tmp2 : tmp3)
This commit is contained in:
parent
76e2aea0f5
commit
9ea852eb0e
|
@ -809,7 +809,7 @@ static bool isOp(const Token *tok)
|
|||
tok->str() == ">" ||
|
||||
tok->str() == ">=" ||
|
||||
tok->str() == "<<" ||
|
||||
Token::Match(tok, "[+-*/%&|,[])]")));
|
||||
Token::Match(tok, "[+-*/%&|,[])?:]")));
|
||||
}
|
||||
|
||||
void CheckOther::functionVariableUsage()
|
||||
|
|
|
@ -66,6 +66,7 @@ private:
|
|||
|
||||
TEST_CASE( localvarMod ); // Usage with modulo
|
||||
TEST_CASE( localvarIf ); // Usage in if
|
||||
TEST_CASE( localvarIfElse ); // return tmp1 ? tmp2 : tmp3;
|
||||
}
|
||||
|
||||
void structmember1()
|
||||
|
@ -223,6 +224,18 @@ private:
|
|||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
void localvarIfElse()
|
||||
{
|
||||
functionVariableUsage( "int foo()\n"
|
||||
"{\n"
|
||||
" int tmp1 = 1;\n"
|
||||
" int tmp2 = 2;\n"
|
||||
" int tmp3 = 3;\n"
|
||||
" return tmp1 ? tmp2 : tmp3;\n"
|
||||
"}\n" );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue