Fixed creation of SymbolDatabase for some template code (#7594)
This commit is contained in:
parent
44a19b527e
commit
c1594bedbb
|
@ -101,7 +101,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
tok2->next()->link()->strAt(1) == ";")
|
||||
tok = tok2->next()->link()->next();
|
||||
// skip variable declaration
|
||||
else if (Token::Match(tok2, "*|&"))
|
||||
else if (Token::Match(tok2, "*|&|>"))
|
||||
continue;
|
||||
else
|
||||
break; // bail
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
TEST_CASE(localvar46); // ticket #5491 (C++11 style initialization)
|
||||
TEST_CASE(localvar47); // ticket #6603
|
||||
TEST_CASE(localvar48); // ticket #6954
|
||||
TEST_CASE(localvar49); // ticket #7594
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1936,6 +1937,27 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar49() { // #7594
|
||||
functionVariableUsage("class A {\n"
|
||||
" public:\n"
|
||||
" typedef enum { ID1,ID2,ID3 } Id_t;\n"
|
||||
" typedef struct {Id_t id; std::string a; } x_t;\n"
|
||||
" std::vector<x_t> m_vec;\n"
|
||||
" std::vector<x_t> Get(void);\n"
|
||||
" void DoSomething();\n"
|
||||
"};\n"
|
||||
"std::vector<A::x_t> A::Get(void) {\n"
|
||||
" return m_vec;\n"
|
||||
"}\n"
|
||||
"const std::string Bar() {\n"
|
||||
" return \"x\";\n"
|
||||
"}\n"
|
||||
"void A::DoSomething(void) {\n"
|
||||
" const std::string x = Bar();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:16]: (style) Variable 'x' is assigned a value that is never used.\n", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1() {
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue