diff --git a/lib/library.cpp b/lib/library.cpp index 5f0952833..5460e1c0c 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -683,7 +683,7 @@ bool Library::isNotLibraryFunction(const Token *ftok) const { // called from tokenizer, ast is not created properly yet if (Token::Match(ftok->previous(),"::|.")) - return false; + return true; int callargs = 0; for (const Token *tok = ftok->tokAt(2); tok && tok->str() != ")"; tok = tok->next()) { diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 308a2253f..5c16f496d 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -2280,7 +2280,7 @@ private: " foo::memset(str, 0, 100);\n" " std::memset(str, 0, 100);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: str\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: str\n", "", errout.str()); // #5257 - check strings checkstd("void f() {\n" diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp index ec737a512..aa117623e 100644 --- a/test/testlibrary.cpp +++ b/test/testlibrary.cpp @@ -31,7 +31,8 @@ private: void run() { TEST_CASE(empty); TEST_CASE(function); - TEST_CASE(function_match); + TEST_CASE(function_match_scope); + TEST_CASE(function_match_args); TEST_CASE(function_arg); TEST_CASE(function_arg_any); TEST_CASE(function_arg_valid); @@ -79,7 +80,38 @@ private: ASSERT(library.isnotnoreturn(tokenList.front())); } - void function_match() const { + void function_match_scope() const { + const char xmldata[] = "\n" + "\n" + " \n" + " " + " \n" + ""; + tinyxml2::XMLDocument doc; + doc.Parse(xmldata, sizeof(xmldata)); + + { + TokenList tokenList(nullptr); + std::istringstream istr("fred.foo(123);"); // <- wrong scope, not library function + tokenList.createTokens(istr); + + Library library; + library.load(doc); + ASSERT(library.isNotLibraryFunction(tokenList.front()->tokAt(2))); + } + + { + TokenList tokenList(nullptr); + std::istringstream istr("Fred::foo(123);"); // <- wrong scope, not library function + tokenList.createTokens(istr); + + Library library; + library.load(doc); + ASSERT(library.isNotLibraryFunction(tokenList.front()->tokAt(2))); + } + } + + void function_match_args() const { const char xmldata[] = "\n" "\n" " \n"