sizeof for numeric constant : disabled check. see ticket #3179
This commit is contained in:
parent
c0770f0823
commit
522da8d258
|
@ -333,6 +333,11 @@ void CheckOther::fflushOnInputStreamError(const Token *tok, const std::string &v
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkSizeofForNumericParameter()
|
||||
{
|
||||
// TODO: write sensible error message if char constant is used
|
||||
// see ticket #3179
|
||||
if (!_settings->experimental)
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "sizeof ( %num% )")
|
||||
|| Token::Match(tok, "sizeof %num%")
|
||||
|
|
|
@ -3070,25 +3070,29 @@ private:
|
|||
void sizeofForNumericParameter() {
|
||||
check("void f() {\n"
|
||||
" std::cout << sizeof(10) << std::endl;\n"
|
||||
"}\n"
|
||||
"}\n",
|
||||
NULL, true
|
||||
);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Using sizeof with a numeric constant as function argument might not be what you intended.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" std::cout << sizeof(-10) << std::endl;\n"
|
||||
"}\n"
|
||||
"}\n",
|
||||
NULL, true
|
||||
);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Using sizeof with a numeric constant as function argument might not be what you intended.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" std::cout << sizeof 10 << std::endl;\n"
|
||||
"}\n"
|
||||
"}\n",
|
||||
NULL, true
|
||||
);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Using sizeof with a numeric constant as function argument might not be what you intended.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" std::cout << sizeof -10 << std::endl;\n"
|
||||
"}\n"
|
||||
"}\n",
|
||||
NULL, true
|
||||
);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Using sizeof with a numeric constant as function argument might not be what you intended.\n", errout.str());
|
||||
|
||||
|
|
Loading…
Reference in New Issue