Fixed C++11 right angle bracket issue #5150
This commit is contained in:
parent
6a08c27183
commit
560cf397d3
|
@ -2718,13 +2718,12 @@ 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::Match(token->next(), "%var%|>|&|*|::|,|(|)|{|;"))
|
if (token->next() && !Token::Match(token->next(), "%var%|>|>>|&|*|::|,|(|)|{|;"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check type of open link
|
// Check type of open link
|
||||||
if (type.empty() || type.top()->str() != "<" || (token->str() == ">>" && type.size() < 2)) {
|
if (token->str() == ">>" && type.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
// if > is followed by ; .. "new a<b>;" is expected
|
// if > is followed by ; .. "new a<b>;" is expected
|
||||||
if (Token::simpleMatch(token->next(), ";")) {
|
if (Token::simpleMatch(token->next(), ";")) {
|
||||||
|
@ -3397,6 +3396,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
setVarId();
|
setVarId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Link < with >
|
||||||
|
createLinks2();
|
||||||
|
|
||||||
// Simplify the C alternative tokens (and, or, etc.)
|
// Simplify the C alternative tokens (and, or, etc.)
|
||||||
simplifyCAlternativeTokens();
|
simplifyCAlternativeTokens();
|
||||||
|
|
||||||
|
@ -3407,8 +3409,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// Add std:: in front of std classes, when using namespace std; was given
|
// Add std:: in front of std classes, when using namespace std; was given
|
||||||
simplifyNamespaceStd();
|
simplifyNamespaceStd();
|
||||||
|
|
||||||
createLinks2();
|
|
||||||
|
|
||||||
// Change initialisation of variable to assignment
|
// Change initialisation of variable to assignment
|
||||||
simplifyInitVar();
|
simplifyInitVar();
|
||||||
|
|
||||||
|
|
|
@ -6789,6 +6789,24 @@ private:
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void removeExceptionSpecification1() {
|
||||||
|
|
Loading…
Reference in New Issue