diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index eed34fbf2..6b631b5ae 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6379,11 +6379,12 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source const Token *smartPointerTypeTok = vt2->containerTypeToken; while (Token::Match(smartPointerTypeTok, "%name%|::")) smartPointerTypeTok = smartPointerTypeTok->next(); - if (Token::Match(smartPointerTypeTok, "< %name% > >") && smartPointerTypeTok->next()->type()) { - setType = true; - templateArgType = smartPointerTypeTok->next()->type(); - autovt.smartPointerType = templateArgType; - autovt.type = ValueType::Type::NONSTD; + if (Token::simpleMatch(smartPointerTypeTok, "<")) { + if ((templateArgType = findTypeInNested(smartPointerTypeTok->next(), tok->scope()))) { + setType = true; + autovt.smartPointerType = templateArgType; + autovt.type = ValueType::Type::NONSTD; + } } } else if (parsedecl(vt2->containerTypeToken, &autovt, mDefaultSignedness, mSettings, mIsCpp)) { setType = true; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 327307750..fb7f44315 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -8223,6 +8223,24 @@ private: ASSERT(tok && tok->valueType()); ASSERT_EQUALS("iterator(std :: vector <)", tok->valueType()->str()); } + { + GET_SYMBOL_DB("struct S {\n" + " S() {}\n" + " std::vector> v;\n" + " void f(int i) const;\n" + "};\n" + "void S::f(int i) const {\n" + " for (const auto& c : v)\n" + " c->f(i);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + const Token* tok = tokenizer.tokens(); + tok = Token::findsimplematch(tok, "auto"); + ASSERT(tok && tok->valueType() && tok->scope() && tok->scope()->functionOf); + const Type* smpType = tok->valueType()->smartPointerType; + ASSERT(smpType && smpType == tok->scope()->functionOf->definedType); + } } void valueTypeThis() {