Fixed #4860 (Segfault with another Clucene file)

This commit is contained in:
Daniel Marjamäki 2013-09-02 05:58:55 +02:00
parent a781a83822
commit 6819f5ed18
2 changed files with 18 additions and 1 deletions

View File

@ -3171,7 +3171,7 @@ void Tokenizer::createLinks2()
else if (token->str() == ">" || token->str() == ">>") { else if (token->str() == ">" || token->str() == ">>") {
if (type.empty() || type.top()->str() != "<") // < and > don't match. if (type.empty() || type.top()->str() != "<") // < and > don't match.
continue; continue;
if (token->next() && !token->next()->isName() && !Token::Match(token->next(), ">|&|*|::|,|(|)")) if (token->next() && !Token::Match(token->next(), "%var%|>|&|*|::|,|(|)|{"))
continue; continue;
// Check type of open link // Check type of open link

View File

@ -6441,6 +6441,23 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
{
// #4860
const char code[] = "class A : public B<int> {};";
errout.str("");
Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = tokenizer.tokens();
// B<..>
ASSERT_EQUALS(true, tok->tokAt(5) == tok->linkAt(7));
ASSERT_EQUALS(true, tok->linkAt(5) == tok->tokAt(7));
ASSERT_EQUALS("", errout.str());
}
} }
void removeExceptionSpecification1() { void removeExceptionSpecification1() {