Skip to content

Commit 618354c

Browse files
committed
fix #12302
1 parent 475e456 commit 618354c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/tokenlist.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static bool iscast(const Token *tok, bool cpp)
470470
if (Token::Match(tok->link(), ") %assign%|,|..."))
471471
return false;
472472

473-
if (tok->previous() && tok->previous()->isName() && tok->strAt(-1) != "return" &&
473+
if (tok->previous() && tok->previous()->isName() && !Token::Match(tok->previous(), "return|case") &&
474474
(!cpp || !Token::Match(tok->previous(), "delete|throw")))
475475
return false;
476476

@@ -600,6 +600,10 @@ static bool iscpp11init_impl(const Token * const tok)
600600
if (Token::simpleMatch(castTok->astParent(), "case"))
601601
return true;
602602
}
603+
if (findParent(colonTok->previous(), [](const Token *parent){
604+
return parent->str() == "case";
605+
}))
606+
return true;
603607
const Token* caseTok = colonTok->tokAt(-2);
604608
while (caseTok && Token::Match(caseTok->tokAt(-1), "::|%name%"))
605609
caseTok = caseTok->tokAt(-1);

0 commit comments

Comments
 (0)