Fixed #1810 (False positive: Variable 'separator' is assigned a value that is never used)
This commit is contained in:
parent
a5b45a7f83
commit
fac9f66cc0
|
@ -2822,6 +2822,7 @@ void Tokenizer::setVarId()
|
|||
if (Token::Match(tok2->next(), "%num%") ||
|
||||
Token::Match(tok2->next(), "%bool%") ||
|
||||
tok2->next()->str()[0] == '"' ||
|
||||
tok2->next()->str()[0] == '\'' ||
|
||||
tok2->next()->varId() != 0)
|
||||
{
|
||||
// This is not a function
|
||||
|
|
|
@ -134,6 +134,7 @@ private:
|
|||
TEST_CASE(varid14);
|
||||
TEST_CASE(varid15);
|
||||
TEST_CASE(varid16);
|
||||
TEST_CASE(varid17); // ticket #1810
|
||||
TEST_CASE(varidStl);
|
||||
TEST_CASE(varid_delete);
|
||||
TEST_CASE(varid_functions);
|
||||
|
@ -1869,6 +1870,24 @@ private:
|
|||
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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue