Fix lambda capture template syntax error (#4593)

This commit is contained in:
Stefan van Kessel 2022-11-23 20:15:10 +01:00 committed by GitHub
parent f6c2afa2ea
commit a5c16af16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -7756,7 +7756,7 @@ void Tokenizer::findGarbageCode() const
syntaxError(tok);
if (Token::Match(tok, ";|(|[ %comp%"))
syntaxError(tok);
if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "[|,|%num% &|=|> ]")))
if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "%type%|[|,|%num% &|=|> ]")))
syntaxError(tok);
if (Token::Match(tok, "[+-] [;,)]}]") && !(isCPP() && Token::Match(tok->previous(), "operator [+-] ;")))
syntaxError(tok);

View File

@ -6754,6 +6754,12 @@ private:
" for (my_struct ms : { my_struct{ .x=5, .y{42} } }) {} "
"}"));
ASSERT_NO_THROW(tokenizeAndStringify("template <typename T> void foo() {} "
"void h() { "
" [func=foo<int>]{func();}(); "
"}"));
// op op
ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { dostuff (x==>y); }"), InternalError, "syntax error: == >");