Fixed #9038 (Auto type with explicit pointer symbol detected as integer)

This commit is contained in:
Daniel Marjamäki 2020-04-19 20:08:47 +02:00
parent f1f9f1f6fb
commit 219180b00a
2 changed files with 13 additions and 0 deletions

View File

@ -5672,6 +5672,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
valuetype->smartPointerType = argTok->next()->type();
valuetype->type = ValueType::Type::NONSTD;
type = argTok->link();
if (type)
type = type->next();
continue;
} else if (Token::Match(type, "%name% :: %name%")) {
std::string typestr;

View File

@ -156,6 +156,7 @@ private:
TEST_CASE(VariableValueType2);
TEST_CASE(VariableValueType3);
TEST_CASE(VariableValueType4); // smart pointer type
TEST_CASE(VariableValueType5); // smart pointer type
TEST_CASE(findVariableType1);
TEST_CASE(findVariableType2);
@ -950,6 +951,16 @@ private:
ASSERT(x->valueType()->smartPointerType);
}
void VariableValueType5() {
GET_SYMBOL_DB("class C {};\n"
"void foo(std::shared_ptr<C>* p) {}\n");
const Variable* const p = db->getVariableFromVarId(1);
ASSERT(p->valueType());
ASSERT(p->valueType()->smartPointerTypeToken);
ASSERT(p->valueType()->pointer == 1);
}
void findVariableType1() {
GET_SYMBOL_DB("class A {\n"
"public:\n"