Fix issue 9136: Syntax error on valid C++14 code: createLinks2() failed
This commit is contained in:
parent
8cbd9b03aa
commit
ce96ec2773
|
@ -3870,7 +3870,8 @@ void Tokenizer::createLinks2()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if > is followed by [ .. "new a<b>[" is expected
|
// if > is followed by [ .. "new a<b>[" is expected
|
||||||
if (token->strAt(1) == "[") {
|
// unless this is from varidiac expansion
|
||||||
|
if (token->strAt(1) == "[" && !Token::simpleMatch(token->tokAt(-3), ". . . >")) {
|
||||||
Token *prev = type.top()->previous();
|
Token *prev = type.top()->previous();
|
||||||
while (prev && Token::Match(prev->previous(), ":: %name%"))
|
while (prev && Token::Match(prev->previous(), ":: %name%"))
|
||||||
prev = prev->tokAt(-2);
|
prev = prev->tokAt(-2);
|
||||||
|
|
|
@ -4808,6 +4808,18 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ::")->link());
|
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ::")->link());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// #9136
|
||||||
|
const char code[] = "template <char> char * a;\n"
|
||||||
|
"template <char... b> struct c {\n"
|
||||||
|
" void d() { a<b...>[0]; }\n"
|
||||||
|
"};\n";
|
||||||
|
Tokenizer tokenizer(&settings0, this);
|
||||||
|
std::istringstream istr(code);
|
||||||
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> [")->link());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyString() {
|
void simplifyString() {
|
||||||
|
|
Loading…
Reference in New Issue