Skip to content

Commit caa3b75

Browse files
Fix #13576 FP: syntaxError when enum is initialized from lambda expression (#7253)
1 parent 5aecba2 commit caa3b75

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/tokenlist.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ const Token* findLambdaEndTokenWithoutAST(const Token* tok) {
14471447
tok = tok->link()->next();
14481448
if (Token::simpleMatch(tok, "mutable"))
14491449
tok = tok->next();
1450-
if (Token::simpleMatch(tok, ".")) { // trailing return type
1450+
if (Token::Match(tok, ".|->")) { // trailing return type
14511451
tok = tok->next();
14521452
while (Token::Match(tok, "%type%|%name%|::|&|&&|*|<|(")) {
14531453
if (tok->link())

test/testgarbage.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ class TestGarbage : public TestFixture {
17641764
}
17651765
void garbageCode228() {
17661766
ASSERT_NO_THROW(checkCode("void f() { enum { A = [=]() mutable { return 0; }() }; }"));
1767+
ASSERT_NO_THROW(checkCode("enum { A = [=](void) mutable -> int { return 0; }() };"));
17671768
}
17681769

17691770
void syntaxErrorFirstToken() {

0 commit comments

Comments
 (0)