Fixed #702 (If you see this, there is a bug - varid was 0)
This commit is contained in:
parent
4d2a8608a8
commit
faac5bccd6
|
@ -926,7 +926,10 @@ void Tokenizer::setVarId()
|
|||
if (Token::Match(tok, "[,;{}(] %type%"))
|
||||
tok = tok->next();
|
||||
|
||||
if (Token::Match(tok, "else|return|typedef|delete|class"))
|
||||
if (Token::Match(tok, "class|struct %type% :|{|;"))
|
||||
continue;
|
||||
|
||||
if (Token::Match(tok, "else|return|typedef|delete"))
|
||||
continue;
|
||||
|
||||
if (Token::Match(tok, "const|static|extern|public:|private:|protected:"))
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
TEST_CASE(varid9);
|
||||
TEST_CASE(varid10);
|
||||
TEST_CASE(varid11);
|
||||
TEST_CASE(varid12);
|
||||
TEST_CASE(varidStl);
|
||||
TEST_CASE(varid_delete);
|
||||
TEST_CASE(varid_functions);
|
||||
|
@ -1217,6 +1218,30 @@ private:
|
|||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void varid12()
|
||||
{
|
||||
const std::string code("static void a()\n"
|
||||
"{\n"
|
||||
" class Foo *foo;\n"
|
||||
"}\n");
|
||||
|
||||
// tokenize..
|
||||
Tokenizer tokenizer;
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
tokenizer.setVarId();
|
||||
|
||||
// result..
|
||||
const std::string actual(tokenizer.tokens()->stringifyList(true));
|
||||
const std::string expected("\n\n##file 0\n"
|
||||
"1: static void a ( )\n"
|
||||
"2: {\n"
|
||||
"3: class Foo * foo@1 ;\n"
|
||||
"4: }\n");
|
||||
|
||||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void varidStl()
|
||||
{
|
||||
const std::string code("list<int> ints;\n"
|
||||
|
|
Loading…
Reference in New Issue