Fix internalAstError with switch/case (#4739)
This commit is contained in:
parent
58de191b99
commit
c50339804b
|
@ -651,7 +651,7 @@ static bool iscpp11init_impl(const Token * const tok)
|
|||
}
|
||||
|
||||
auto isCaseStmt = [](const Token* colonTok) {
|
||||
if (!Token::Match(colonTok->tokAt(-1), "%name%|%num% :"))
|
||||
if (!Token::Match(colonTok->tokAt(-1), "%name%|%num%|%char% :"))
|
||||
return false;
|
||||
const Token* caseTok = colonTok->tokAt(-2);
|
||||
while (caseTok && Token::Match(caseTok->tokAt(-1), "::|%name%"))
|
||||
|
|
|
@ -6558,6 +6558,17 @@ private:
|
|||
" });\n"
|
||||
"}\n"));
|
||||
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("void f(const std::vector<char>& v) {\n"
|
||||
" std::for_each(v.begin(), v.end(), [&](char c) {\n"
|
||||
" switch (c) {\n"
|
||||
" case 'r': {\n"
|
||||
" if (c) {}\n"
|
||||
" }\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" });\n"
|
||||
"}\n"));
|
||||
|
||||
// #11378
|
||||
ASSERT_EQUALS("gT{(&[{= 0return", testAst("auto g = T{ [&]() noexcept -> int { return 0; } };"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue