Skip to content
5 changes: 5 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6538,6 +6538,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
setValueType(tok, valuetype);
}

else if (Token::simpleMatch(tok->previous(), "= {") && tok->tokAt(-2) && tok->tokAt(-2)->valueType()) {
ValueType vt = *tok->tokAt(-2)->valueType();
setValueType(tok, vt);
}

// library type/function
else if (tok->previous()) {
if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) {
Expand Down
7 changes: 7 additions & 0 deletions test/testautovariables.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,13 @@ class TestAutoVariables : public TestFixture {
true);
ASSERT_EQUALS("", errout.str());

check("std::string f(std::string s) {\n"
" std::string r = { s.begin(), s.end() };\n"
" return r;\n"
"}\n",
true);
ASSERT_EQUALS("", errout.str());

check("struct A {\n"
" std::vector<std::unique_ptr<int>> mA;\n"
" void f(std::unique_ptr<int> a) {\n"
Expand Down