Fix issue 9141: Syntax error (#1853)
This commit is contained in:
parent
d594b195d4
commit
61935802d1
|
@ -3847,7 +3847,7 @@ void Tokenizer::createLinks2()
|
|||
|
||||
while (!type.empty() && type.top()->str() == "<") {
|
||||
const Token* end = type.top()->findClosingBracket();
|
||||
if (Token::Match(end, "> ;|>"))
|
||||
if (Token::Match(end, "> ;|%comp%"))
|
||||
break;
|
||||
// Variable declaration
|
||||
if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{")))
|
||||
|
@ -3871,7 +3871,7 @@ void Tokenizer::createLinks2()
|
|||
if (token->str() == ">>")
|
||||
continue;
|
||||
if (token->next() &&
|
||||
!Token::Match(token->next(), "%name%|>|&|&&|*|::|,|(|)|{|}|;|[|:") &&
|
||||
!Token::Match(token->next(), "%name%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:") &&
|
||||
!Token::simpleMatch(token->next(), ". . .") &&
|
||||
!Token::Match(token->next(), "&& %name% ="))
|
||||
continue;
|
||||
|
|
|
@ -4858,6 +4858,21 @@ private:
|
|||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> > ;")->link());
|
||||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ;")->link());
|
||||
}
|
||||
|
||||
{
|
||||
// #9141
|
||||
const char code[] = "struct a {\n"
|
||||
" typedef int b;\n"
|
||||
" operator b();\n"
|
||||
"};\n"
|
||||
"template <int> using c = a;\n"
|
||||
"template <int d> c<d> e;\n"
|
||||
"auto f = -e<1> == 0;\n";
|
||||
Tokenizer tokenizer(&settings0, this);
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ==")->link());
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyString() {
|
||||
|
|
Loading…
Reference in New Issue