diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index 8184cd348..9fed59429 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -50,33 +50,6 @@ void CheckInternal::checkTokenMatchPatterns() continue; } - const char *p = pattern.c_str(); - while (*p) { - while (*p && std::isspace(*p)) - p++; - const char *start = p; - while (*p && !std::isspace(*p)) - p++; - const char *end = p - 1; - if (start < end && !(*start == '[' && *end == ']')) { - bool cmd = (*start=='%' && std::isalpha(*(start+1))); - // check multicompare pattern.. - for (const char *s = start; s != end; s++) { - if (*s == '|') { - if (!(*(s+1) == '%' && std::isalpha(*(s+2)))) { - cmd = false; - } else if (!cmd && - std::strncmp(s+1,"%op%",4)!=0 && - std::strncmp(s+1,"%or%",4)!=0 && - std::strncmp(s+1,"%cop%",5)!=0 && - std::strncmp(s+1,"%name%",5)!=0 && - std::strncmp(s+1,"%oror%",6)!=0) { - multiComparePatternError(tok, pattern, funcname); - } - } - } - } - } if (pattern.find("||") != std::string::npos || pattern.find(" | ") != std::string::npos || pattern[0] == '|' || (pattern[pattern.length() - 1] == '|' && pattern[pattern.length() - 2] == ' ')) orInComplexPattern(tok, pattern, funcname); diff --git a/test/testinternal.cpp b/test/testinternal.cpp index 1606280cb..505dfb768 100644 --- a/test/testinternal.cpp +++ b/test/testinternal.cpp @@ -39,8 +39,7 @@ private: TEST_CASE(missingPercentCharacter) TEST_CASE(unknownPattern) TEST_CASE(redundantNextPrevious) - TEST_CASE(internalError) - TEST_CASE(invalidMultiCompare); + TEST_CASE(internalError); TEST_CASE(orInComplexPattern); TEST_CASE(extraWhitespace); } @@ -237,8 +236,7 @@ private: " const Token *tok;\n" " Token::Match(tok, \"foo|%type|bar\");\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Bad multicompare pattern (a %cmd% must be first unless it is %or%,%op%,%cop%,%name%,%oror%) inside Token::Match() call: \"foo|%type|bar\"\n" - "[test.cpp:3]: (error) Missing percent end character in Token::Match() pattern: \"foo|%type|bar\"\n" + ASSERT_EQUALS("[test.cpp:3]: (error) Missing percent end character in Token::Match() pattern: \"foo|%type|bar\"\n" , errout.str()); // Make sure we don't take %or% for a broken %oror% @@ -330,27 +328,6 @@ private: ASSERT_EQUALS("", errout.str()); } - void invalidMultiCompare() { - // #5310 - check("void f() {\n" - " const Token *tok;\n" - " Token::Match(tok, \";|%type%\");\n" - "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Bad multicompare pattern (a %cmd% must be first unless it is %or%,%op%,%cop%,%name%,%oror%) inside Token::Match() call: \";|%type%\"\n", errout.str()); - - check("void f() {\n" - " const Token *tok;\n" - " Token::Match(tok, \";|%oror%\");\n" - "}"); - ASSERT_EQUALS("", errout.str()); - - check("void f() {\n" // The %name%|%num% works.. - " const Token *tok;\n" - " Token::Match(tok, \"%name%|%num%\");\n" - "}"); - ASSERT_EQUALS("", errout.str()); - } - void orInComplexPattern() { check("void f() {\n" " Token::Match(tok, \"||\");\n"