parent
a2351ba44f
commit
002389f836
|
@ -3323,7 +3323,7 @@ void Tokenizer::createLinks2()
|
|||
} else if (token->str() == ">" || token->str() == ">>") {
|
||||
if (links.empty()) // < and > don't match.
|
||||
continue;
|
||||
if (token->next() && !token->next()->isName() && !Token::Match(token->next(), ">|&|*|::|,"))
|
||||
if (token->next() && !token->next()->isName() && !Token::Match(token->next(), ">|&|*|::|,|("))
|
||||
continue;
|
||||
|
||||
// Check type of open link
|
||||
|
|
|
@ -5017,6 +5017,8 @@ private:
|
|||
// f ()
|
||||
ASSERT_EQUALS(true, tok->linkAt(5) == tok->tokAt(6));
|
||||
ASSERT_EQUALS(true, tok->linkAt(6) == tok->tokAt(5));
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -5041,6 +5043,8 @@ private:
|
|||
// a[0]
|
||||
ASSERT_EQUALS(true, tok->linkAt(21) == tok->tokAt(23));
|
||||
ASSERT_EQUALS(true, tok->linkAt(23) == tok->tokAt(21));
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -5060,6 +5064,8 @@ private:
|
|||
// g(
|
||||
ASSERT_EQUALS(true, tok->linkAt(8) == tok->tokAt(9));
|
||||
ASSERT_EQUALS(true, tok->linkAt(9) == tok->tokAt(8));
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -5087,6 +5093,26 @@ private:
|
|||
// a<b && b>f
|
||||
ASSERT_EQUALS(0, (long long)tok->linkAt(28));
|
||||
ASSERT_EQUALS(0, (long long)tok->linkAt(32));
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void foo() {\n"
|
||||
" return static_cast<bar>(a);\n"
|
||||
"}";
|
||||
errout.str("");
|
||||
Settings settings;
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
const Token *tok = tokenizer.tokens();
|
||||
|
||||
// static_cast<
|
||||
ASSERT_EQUALS((long long)tok->tokAt(9), (long long)tok->linkAt(7));
|
||||
ASSERT_EQUALS((long long)tok->tokAt(7), (long long)tok->linkAt(9));
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ private:
|
|||
TEST_CASE(localvarUnused);
|
||||
TEST_CASE(localvarFunction); // ticket #1799
|
||||
TEST_CASE(localvarIfNOT); // #3104 - if ( NOT var )
|
||||
TEST_CASE(localvarAnd); // #3672
|
||||
}
|
||||
|
||||
void checkStructMemberUsage(const char code[]) {
|
||||
|
@ -3005,6 +3006,16 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarAnd() { // #3672
|
||||
functionVariableUsage("int main() {\n"
|
||||
" unsigned flag = 0x1 << i;\n"
|
||||
" if (m_errorflags & flag) {\n"
|
||||
" return 1;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestUnusedVar)
|
||||
|
|
Loading…
Reference in New Issue