diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 66a7196d8..6789b53bd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9140,7 +9140,7 @@ void Tokenizer::findGarbageCode() const if (Token::Match(tok, "> %cop%")) continue; } - if (Token::Match(tok, "%or%|%oror%|==|!=|+|-|/|!|>=|<=|~|++|--|::|sizeof|throw|decltype|typeof {|if|else|try|catch|while|do|for|return|switch|break|namespace")) + if (Token::Match(tok, "%or%|%oror%|==|!=|+|-|/|!|>=|<=|~|^|++|--|::|sizeof|throw|decltype|typeof {|if|else|try|catch|while|do|for|return|switch|break|namespace")) syntaxError(tok); if (Token::Match(tok, "( %any% )") && tok->next()->isKeyword() && !Token::simpleMatch(tok->next(), "void")) syntaxError(tok); diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 5cc0a0f2c..4f53863cd 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -245,6 +245,7 @@ private: TEST_CASE(syntaxErrorLastToken); // Make sure syntax errors are detected and reported TEST_CASE(syntaxErrorCase); TEST_CASE(syntaxErrorFuzzerCliType1); + TEST_CASE(cliCode); TEST_CASE(enumTrailingComma); TEST_CASE(nonGarbageCode1); // #8346 @@ -1662,6 +1663,16 @@ private: ASSERT_THROW(checkCode("void f() { x= y{ } name5 y[ ] + y ^ name5 ^ name5 for ( ( y y y && y y y && name5 ++ int )); }"), InternalError); // #9069 } + void cliCode() { + // #8913 + ASSERT_THROW(checkCode("public ref class LibCecSharp : public CecCallbackMethods {\n" + "array ^ FindAdapters(String ^ path) {} \n" + "bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs) {\n" + "bool bReturn(false);\n" + "}\n" + "};\n"), InternalError); + } + void enumTrailingComma() { ASSERT_THROW(checkCode("enum ssl_shutdown_t {ssl_shutdown_none = 0,ssl_shutdown_close_notify = , } ;"), InternalError); // #8079 }