Fix #11369 Syntax error. Unexpected tokens in initializer. (#4568)

This commit is contained in:
chrchr-github 2022-10-29 21:24:50 +02:00 committed by GitHub
parent 8672e12a7a
commit 6df8573e15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -626,7 +626,8 @@ static bool iscpp11init_impl(const Token * const tok)
}
if (!nameToken)
return false;
if (nameToken->str() == ")" && Token::simpleMatch(nameToken->link()->previous(), "decltype ("))
if (nameToken->str() == ")" && Token::simpleMatch(nameToken->link()->previous(), "decltype (") &&
!Token::simpleMatch(nameToken->link()->tokAt(-2), "."))
return true;
if (Token::simpleMatch(nameToken, ", {"))
return true;

View File

@ -6377,6 +6377,12 @@ private:
ASSERT_EQUALS("AB: abc+=", testAst("struct A : public B<C*> { void f() { a=b+c; } };"));
ASSERT_EQUALS("xfts(=", testAst("; auto x = f(ts...);"));
// #11369
ASSERT_NO_THROW(tokenizeAndStringify("int a;\n"
"template <class> auto b() -> decltype(a) {\n"
" if (a) {}\n"
"}\n"));
}
void astcast() {