Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5271,6 +5271,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)

static const Token * parsedecl(const Token *type, ValueType * const valuetype, ValueType::Sign defaultSignedness, const Settings* settings)
{
const Token * const previousType = type;
const unsigned int pointer0 = valuetype->pointer;
while (Token::Match(type->previous(), "%name%"))
type = type->previous();
Expand Down Expand Up @@ -5305,7 +5306,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
valuetype->sign = ValueType::Sign::UNSIGNED;
if (valuetype->type == ValueType::Type::UNKNOWN_TYPE &&
type->type() && type->type()->isTypeAlias() && type->type()->typeStart &&
type->type()->typeStart->str() != type->str())
type->type()->typeStart->str() != type->str() && type->type()->typeStart != previousType)
parsedecl(type->type()->typeStart, valuetype, defaultSignedness, settings);
else if (type->str() == "const")
valuetype->constness |= (1 << (valuetype->pointer - pointer0));
Expand Down
21 changes: 21 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ class TestSymbolDatabase: public TestFixture {
TEST_CASE(auto12); // #8993 - const std::string &x; auto y = x; if (y.empty()) ..

TEST_CASE(unionWithConstructor);

TEST_CASE(incomplete_type); // #9255 (infinite recursion)
}

void array() {
Expand Down Expand Up @@ -7072,6 +7074,25 @@ class TestSymbolDatabase: public TestFixture {
f = Token::findsimplematch(tokenizer.tokens(), "Fred ( float");
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 3);
}

void incomplete_type() {
GET_SYMBOL_DB("template<class _Ty,\n"
" class _Alloc = std::allocator<_Ty>>\n"
" class SLSurfaceLayerData\n"
" : public _Vector_alloc<_Vec_base_types<_Ty, _Alloc>>\n"
"{ // varying size array of values\n"
"\n"
" using reverse_iterator = _STD reverse_iterator<iterator>;\n"
" using const_reverse_iterator = _STD reverse_iterator<const_iterator>;\n"
" const_reverse_iterator crend() const noexcept\n"
" { // return iterator for end of reversed nonmutable sequence\n"
" return (rend());\n"
" }\n"
"};");
(void)db;

ASSERT_EQUALS("", errout.str());
}
};

REGISTER_TEST(TestSymbolDatabase)