From f611c9aec709d58056f2621866e111cdfea29da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 24 Jan 2011 18:15:56 +0100 Subject: [PATCH 1/2] cleanup old ifdefs in cmdlineparser --- cli/cmdlineparser.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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) From c7b8bd543f885bb90838ccd4f86c32cc315a7d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Debrard?= Date: Mon, 24 Jan 2011 19:04:56 +0100 Subject: [PATCH 2/2] fix ticket 155 - char array --- lib/checkother.cpp | 2 +- test/testother.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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()); + + } };