From 2a33c3cfecdeb48af8105b090d62ca0a59dbd115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 3 Oct 2019 21:28:41 +0200 Subject: [PATCH] SymbolDatabase: Add test to ensure findFunction looks in current scope first --- test/testsymboldatabase.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 1ffd8b92d..7610373d0 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -345,6 +345,7 @@ private: TEST_CASE(findFunction25); // std::vector> TEST_CASE(findFunction26); // #8668 - pointer parameter in function call, const pointer function argument TEST_CASE(findFunction27); + TEST_CASE(findFunction28); TEST_CASE(findFunctionContainer); TEST_CASE(valueTypeMatchParameter); // ValueType::matchParameter @@ -5577,6 +5578,19 @@ private: ASSERT(a->function()); } + void findFunction28() { + GET_SYMBOL_DB("namespace { void a(int); }\n" + "struct S {\n" + " void foo() { a(7); }\n" + " void a(int);\n" + "};"); + const Token *a = Token::findsimplematch(tokenizer.tokens(), "a ( 7 )"); + ASSERT(a); + ASSERT(a->function()); + ASSERT(a->function()->token); + ASSERT_EQUALS(4, a->function()->token->linenr()); + } + void findFunctionContainer() { { GET_SYMBOL_DB("void dostuff(std::vector v);\n"