Fixed C++11 right angle bracket issue #5150

This commit is contained in:
PKEuS 2014-03-22 13:33:34 +01:00
parent 6a08c27183
commit 560cf397d3
2 changed files with 23 additions and 5 deletions

View File

@ -2718,13 +2718,12 @@ void Tokenizer::createLinks2()
else if (token->str() == ">" || token->str() == ">>") {
if (type.empty() || type.top()->str() != "<") // < and > don't match.
continue;
if (token->next() && !Token::Match(token->next(), "%var%|>|&|*|::|,|(|)|{|;"))
if (token->next() && !Token::Match(token->next(), "%var%|>|>>|&|*|::|,|(|)|{|;"))
continue;
// Check type of open link
if (type.empty() || type.top()->str() != "<" || (token->str() == ">>" && type.size() < 2)) {
if (token->str() == ">>" && type.size() < 2)
continue;
}
// if > is followed by ; .. "new a<b>;" is expected
if (Token::simpleMatch(token->next(), ";")) {
@ -3397,6 +3396,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
setVarId();
}
// Link < with >
createLinks2();
// Simplify the C alternative tokens (and, or, etc.)
simplifyCAlternativeTokens();
@ -3407,8 +3409,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Add std:: in front of std classes, when using namespace std; was given
simplifyNamespaceStd();
createLinks2();
// Change initialisation of variable to assignment
simplifyInitVar();

View File

@ -6789,6 +6789,24 @@ private:
ASSERT_EQUALS("", errout.str());
}
{
// #4860
const char code[] = "Bar<Typelist< int, Typelist< int, Typelist< int, FooNullType>>>>::set(1, 2, 3);";
errout.str("");
Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = tokenizer.tokens();
ASSERT_EQUALS(true, tok->tokAt(1) == tok->linkAt(18));
ASSERT_EQUALS(true, tok->tokAt(3) == tok->linkAt(17));
ASSERT_EQUALS(true, tok->tokAt(7) == tok->linkAt(16));
ASSERT_EQUALS(true, tok->tokAt(11) == tok->linkAt(15));
ASSERT_EQUALS("", errout.str());
}
}
void removeExceptionSpecification1() {