This commit is contained in:
Sébastien Debrard 2011-01-24 20:31:53 +01:00
commit 3445e77126
3 changed files with 12 additions and 9 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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());
}
};