Fixed #1810 (False positive: Variable 'separator' is assigned a value that is never used)

This commit is contained in:
Robert Reif 2010-06-22 17:07:41 +02:00 committed by Daniel Marjamäki
parent a5b45a7f83
commit fac9f66cc0
2 changed files with 20 additions and 0 deletions

View File

@ -2822,6 +2822,7 @@ void Tokenizer::setVarId()
if (Token::Match(tok2->next(), "%num%") || if (Token::Match(tok2->next(), "%num%") ||
Token::Match(tok2->next(), "%bool%") || Token::Match(tok2->next(), "%bool%") ||
tok2->next()->str()[0] == '"' || tok2->next()->str()[0] == '"' ||
tok2->next()->str()[0] == '\'' ||
tok2->next()->varId() != 0) tok2->next()->varId() != 0)
{ {
// This is not a function // This is not a function

View File

@ -134,6 +134,7 @@ private:
TEST_CASE(varid14); TEST_CASE(varid14);
TEST_CASE(varid15); TEST_CASE(varid15);
TEST_CASE(varid16); TEST_CASE(varid16);
TEST_CASE(varid17); // ticket #1810
TEST_CASE(varidStl); TEST_CASE(varidStl);
TEST_CASE(varid_delete); TEST_CASE(varid_delete);
TEST_CASE(varid_functions); TEST_CASE(varid_functions);
@ -1869,6 +1870,24 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code)); ASSERT_EQUALS(expected, tokenizeDebugListing(code));
} }
void varid17() // ticket #1810
{
const std::string code("char foo()\n"
"{\n"
" char c('c');\n"
" return c;\n"
"}\n");
const std::string expected("\n\n##file 0\n"
"1: char foo ( )\n"
"2: {\n"
"3: char c@1 ( 'c' ) ;\n"
"4: return c@1 ;\n"
"5: }\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varidStl() void varidStl()
{ {