diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 52b33d0a6..fe6ab2d26 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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 diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 1c4af55c4..c6bd4dde7 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -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 m_vec;\n" + " std::vector Get(void);\n" + " void DoSomething();\n" + "};\n" + "std::vector 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"