diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5af99c21ec2..38865e535d4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3346,8 +3346,10 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration) if (mTimerResults) { Timer t("Tokenizer::simplifyTokens1::setValueType", mSettings->showtime, mTimerResults); + mSymbolDatabase->setValueTypeInTokenList(false); mSymbolDatabase->setValueTypeInTokenList(true); } else { + mSymbolDatabase->setValueTypeInTokenList(false); mSymbolDatabase->setValueTypeInTokenList(true); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 8c2bec6bd8f..ff8448e7be0 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -509,6 +509,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(auto17); // #11163 TEST_CASE(auto18); TEST_CASE(auto19); + TEST_CASE(auto20); TEST_CASE(unionWithConstructor); @@ -9419,6 +9420,22 @@ class TestSymbolDatabase : public TestFixture { } } + void auto20() { + GET_SYMBOL_DB("enum A { A0 };\n" + "enum B { B0 };\n" + "const int& g(A a);\n" + "const int& g(B b);\n" + "void f() {\n" + " const auto& r = g(B::B0);\n" + "}\n"); + const Token* a = Token::findsimplematch(tokenizer.tokens(), "auto"); + ASSERT(a && a->valueType()); + ASSERT_EQUALS(a->valueType()->type, ValueType::INT); + const Token* g = Token::findsimplematch(a, "g ( B ::"); + ASSERT(g && g->function()); + ASSERT_EQUALS(g->function()->tokenDef->linenr(), 4); + } + void unionWithConstructor() { GET_SYMBOL_DB("union Fred {\n" " Fred(int x) : i(x) { }\n"