Fixed #8663 (Stack overflow with template disambiguator) (#1932)

This commit is contained in:
IOBYTE 2019-06-28 16:07:21 -04:00 committed by Daniel Marjamäki
parent 5f759e89b3
commit 8b347aed42
2 changed files with 12 additions and 1 deletions

View File

@ -5194,7 +5194,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
valuetype->type = ValueType::Type::INT;
} else
valuetype->type = ValueType::Type::RECORD;
while (Token::Match(type, "%name%|*|&|::") && !type->variable() && !type->function()) {
while (Token::Match(type, "%name%|*|&|::") && !Token::Match(type, "typename|template") &&
!type->variable() && !type->function()) {
if (type->isSigned())
valuetype->sign = ValueType::Sign::SIGNED;
else if (type->isUnsigned())

View File

@ -297,6 +297,7 @@ private:
TEST_CASE(symboldatabase74); // #8838 - final
TEST_CASE(symboldatabase75);
TEST_CASE(symboldatabase76); // #9056
TEST_CASE(symboldatabase77); // #8663
TEST_CASE(createSymbolDatabaseFindAllScopes1);
@ -4219,6 +4220,15 @@ private:
ASSERT_EQUALS(2, db->mVariableList.size());
}
void symboldatabase77() { // #8663
GET_SYMBOL_DB("template <class T1, class T2>\n"
"void f() {\n"
" using T3 = typename T1::template T3<T2>;\n"
" T3 t;\n"
"}");
ASSERT_EQUALS(2, db->mVariableList.size());
}
void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3);