Fixed #9746 (SymbolDatabase: Wrong valueType for return)
This commit is contained in:
parent
4880f30dc3
commit
3f1f62e078
|
@ -5657,6 +5657,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
||||||
while (Token::Match(type, "%name%|*|&|::|(") && !Token::Match(type, "typename|template") &&
|
while (Token::Match(type, "%name%|*|&|::|(") && !Token::Match(type, "typename|template") &&
|
||||||
!type->variable() && !type->function()) {
|
!type->variable() && !type->function()) {
|
||||||
if (type->str() == "(") {
|
if (type->str() == "(") {
|
||||||
|
if (Token::Match(type->link(), ") const| {"))
|
||||||
|
break;
|
||||||
if (par)
|
if (par)
|
||||||
break;
|
break;
|
||||||
par = true;
|
par = true;
|
||||||
|
@ -6040,6 +6042,12 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (tok->str() == "return") {
|
||||||
|
const Scope *functionScope = tok->scope();
|
||||||
|
while (functionScope && functionScope->isExecutable() && functionScope->type != Scope::eLambda && functionScope->type != Scope::eFunction)
|
||||||
|
functionScope = functionScope->nestedIn;
|
||||||
|
if (functionScope && functionScope->type == Scope::eFunction && functionScope->function && functionScope->function->retDef)
|
||||||
|
setValueType(tok, ValueType::parseDecl(functionScope->function->retDef, mSettings));
|
||||||
} else if (tok->variable()) {
|
} else if (tok->variable()) {
|
||||||
setValueType(tok, *tok->variable());
|
setValueType(tok, *tok->variable());
|
||||||
} else if (tok->enumerator()) {
|
} else if (tok->enumerator()) {
|
||||||
|
|
|
@ -6899,6 +6899,17 @@ private:
|
||||||
|
|
||||||
// std::make_shared
|
// std::make_shared
|
||||||
ASSERT_EQUALS("smart-pointer<C>", typeOf("class C {}; x = std::make_shared<C>();", "("));
|
ASSERT_EQUALS("smart-pointer<C>", typeOf("class C {}; x = std::make_shared<C>();", "("));
|
||||||
|
|
||||||
|
// return
|
||||||
|
{
|
||||||
|
// Container
|
||||||
|
Settings sC;
|
||||||
|
Library::Container c;
|
||||||
|
c.startPattern = "C";
|
||||||
|
c.startPattern2 = "C !!::";
|
||||||
|
sC.library.containers["C"] = c;
|
||||||
|
ASSERT_EQUALS("container(C)", typeOf("C f(char *p) { char data[10]; return data; }", "return", "test.cpp", &sC));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void variadic1() { // #7453
|
void variadic1() { // #7453
|
||||||
|
|
Loading…
Reference in New Issue