Fixed hang on garbage code (#4193)

This commit is contained in:
PKEuS 2012-09-14 15:32:35 +02:00
parent 3e58472cd3
commit 929f16d892
2 changed files with 8 additions and 1 deletions

View File

@ -1630,7 +1630,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
// skip default values
if (tok->str() == "=") {
while (tok->str() != "," && tok->str() != ")") {
if (tok->link())
if (tok->link() && Token::Match(tok, "[{[(<]"))
tok = tok->link();
tok = tok->next();
}

View File

@ -154,6 +154,8 @@ private:
TEST_CASE(symboldatabase28);
TEST_CASE(isImplicitlyVirtual);
TEST_CASE(garbage);
}
void array() {
@ -1380,6 +1382,11 @@ private:
ASSERT(db && db->findScopeByName("Deri") && db->findScopeByName("Deri")->functionList.front().isImplicitlyVirtual(false)); // Default false, but we saw "virtual" -> true
}
}
void garbage() {
GET_SYMBOL_DB("void f( { u = 1 ; } ) { }");
(void)db;
}
};
REGISTER_TEST(TestSymbolDatabase)