Fix issue 9145: Syntax error on valid C++14 code (#1860)
This commit is contained in:
parent
f66cbac0a4
commit
33130bdff6
|
@ -3847,7 +3847,7 @@ void Tokenizer::createLinks2()
|
|||
|
||||
while (!type.empty() && type.top()->str() == "<") {
|
||||
const Token* end = type.top()->findClosingBracket();
|
||||
if (Token::Match(end, "> ;|%comp%"))
|
||||
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%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:") &&
|
||||
!Token::Match(token->next(), "%name%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:|.") &&
|
||||
!Token::simpleMatch(token->next(), ". . .") &&
|
||||
!Token::Match(token->next(), "&& %name% ="))
|
||||
continue;
|
||||
|
|
|
@ -4873,6 +4873,25 @@ private:
|
|||
tokenizer.tokenize(istr, "test.cpp");
|
||||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ==")->link());
|
||||
}
|
||||
|
||||
{
|
||||
// #9145
|
||||
const char code[] = "template <typename a, a> struct b {\n"
|
||||
" template <typename c> constexpr void operator()(c &&) const;\n"
|
||||
"};\n"
|
||||
"template <int d> struct e { b<int, d> f; };\n"
|
||||
"template <int g> using h = e<g>;\n"
|
||||
"template <int g> h<g> i;\n"
|
||||
"template <typename a, a d>\n"
|
||||
"template <typename c>\n"
|
||||
"constexpr void b<a, d>::operator()(c &&) const {\n"
|
||||
" i<3>.f([] {});\n"
|
||||
"}\n";
|
||||
Tokenizer tokenizer(&settings0, this);
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> . f (")->link());
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyString() {
|
||||
|
|
Loading…
Reference in New Issue