From 8b347aed429a1b39d130aa73adef5038afaa77bd Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Fri, 28 Jun 2019 16:07:21 -0400 Subject: [PATCH] Fixed #8663 (Stack overflow with template disambiguator) (#1932) --- lib/symboldatabase.cpp | 3 ++- test/testsymboldatabase.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 19d2cbbf4..6ac10f167 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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()) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 66e4da1a4..2bf77056a 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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 \n" + "void f() {\n" + " using T3 = typename T1::template T3;\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);