diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index c729090e1..afb35ecb7 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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%")) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index cff9b847e..93fe73d81 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6558,6 +6558,17 @@ private: " });\n" "}\n")); + ASSERT_NO_THROW(tokenizeAndStringify("void f(const std::vector& 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; } };")); }