diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4b01b0fcf97..8acfa5876e1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8920,7 +8920,7 @@ void Tokenizer::findGarbageCode() const if (Token::Match(tok, "!|~ %comp%") && !(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator"))) syntaxError(tok); - if (Token::Match(tok, "] %name%") && (!cpp || !(tok->tokAt(-1) && Token::simpleMatch(tok->tokAt(-2), "delete [")))) { + if (Token::Match(tok, "] %name%") && (!cpp || !(tok->tokAt(1)->isKeyword() || (tok->tokAt(-1) && Token::simpleMatch(tok->tokAt(-2), "delete ["))))) { if (tok->next()->isUpperCaseName()) unknownMacroError(tok->next()); else diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7c7142516fb..97ae9f9b9e3 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7994,6 +7994,12 @@ class TestTokenizer : public TestFixture { "int main() { \n" " takesFunc([func = [](S s) { return s.c; }] {});\n" "}\n")); + + ASSERT_NO_THROW(tokenizeAndStringify("void f() {\n" // #14256 + " int i = 0;\n" + " auto x = [i] mutable {};\n" + "}\n")); + ignore_errout(); } void checkIfCppCast() {