diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 4c61ffc08..3038e88f7 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -460,6 +460,13 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } + // Posix compliant code checks + else if (strcmp(argv[i], "--posix") == 0) + { + _settings->_posix = true; + } + + // deprecated: auto deallocated classes.. else if (strcmp(argv[i], "--auto-dealloc") == 0) { @@ -682,6 +689,7 @@ void CmdLineParser::PrintHelp() " more comments, like: // cppcheck-suppress warningId\n" " on the lines before the warning to suppress.\n" " -j Start [jobs] threads to do the checking simultaneously.\n" + " --posix Enable checks applicable only to Posix compliant code.\n" " -q, --quiet Only print error messages.\n" " --report-progress Report progress messages while checking a file.\n" #ifdef HAVE_RULES diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 3e8bc6ce5..dd1f4b10d 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -100,6 +100,7 @@ private: TEST_CASE(ignorefilepaths1) TEST_CASE(ignorefilepaths2) TEST_CASE(checkconfig) + TEST_CASE(posix); TEST_CASE(unknownParam); } @@ -812,6 +813,16 @@ private: ASSERT_EQUALS(true, settings.checkConfiguration); } + void posix() + { + REDIRECT; + const char *argv[] = {"cppcheck", "--posix", "file.cpp"}; + Settings settings; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT_EQUALS(true, settings._posix); + } + void unknownParam() { REDIRECT;