diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index e4143d052..af6e677af 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -170,14 +170,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) else if (strcmp(argv[i], "--xml") == 0) _settings->_xml = true; -#ifndef NDEBUG - // Experimental: Write results in xml2 format + // Write results in xml2 format else if (strcmp(argv[i], "--xml-version=2") == 0) { _settings->_xml = true; _settings->_xml_version = 2; } -#endif // Only print something when there are errors else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) @@ -409,8 +407,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) _settings->_showtime = SHOWTIME_NONE; } -// Rules are a debug feature -#ifndef NDEBUG // Rule given at command line else if (strncmp(argv[i], "--rule=", 7) == 0) { @@ -457,7 +453,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } } -#endif // Print help else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 2ff551e57..d8e065610 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -95,7 +95,7 @@ void CheckOther::checkSizeofForArrayParameter() const Token *declTok = Token::findmatch(_tokenizer->tokens(), "%varid%", tok->tokAt(tokIdx)->varId()); if (declTok) { - if ((Token::simpleMatch(declTok->next(), "[")) && !(Token::simpleMatch(declTok->next()->link(), "] = {")) && !(Token::simpleMatch(declTok->next()->link(), "] ;"))) + if ((Token::simpleMatch(declTok->next(), "[")) && !(Token::Match(declTok->next()->link(), "] = %str%")) && !(Token::simpleMatch(declTok->next()->link(), "] = {")) && !(Token::simpleMatch(declTok->next()->link(), "] ;"))) { sizeofForArrayParameterError(tok); } diff --git a/test/testother.cpp b/test/testother.cpp index 934ab01ca..f71d7eb97 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -98,7 +98,7 @@ private: TEST_CASE(memsetZeroBytes); - TEST_CASE(sizeofWithSilentArrayPointer); + TEST_CASE(sizeofForArrayParameter); } void check(const char code[], const char *filename = NULL) @@ -1663,7 +1663,7 @@ private: ASSERT_EQUALS("", errout.str()); } - void sizeofWithSilentArrayPointer() + void sizeofForArrayParameter() { check("void f() {\n" " int a[10];\n" @@ -1742,6 +1742,14 @@ private: ); ASSERT_EQUALS("", errout.str()); + check("void f() {\n" + " char p[] = \"test\";\n" + " sizeof(p);\n" + "}\n" + ); + ASSERT_EQUALS("", errout.str()); + + } };