commaSeparatedReturn: made checking experimental for now because there are false positives (#5076)

This commit is contained in:
Daniel Marjamäki 2013-10-08 18:05:07 +02:00
parent 90b2c5ddce
commit 9ce7efc6e4
2 changed files with 11 additions and 7 deletions

View File

@ -1882,6 +1882,10 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname
void CheckOther::checkCommaSeparatedReturn()
{
// This is experimental for now. See #5076
if (!_settings->experimental)
return;
if (!_settings->isEnabled("style"))
return;

View File

@ -6625,38 +6625,38 @@ private:
" if (a < 0)\n"
" return a++,\n"
" do_something();\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a++, do_something();\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a+5,\n"
" do_something();\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a+5, do_something();\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return c<int,\nint>::b;\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("", errout.str());
// ticket #4927 Segfault in CheckOther::checkCommaSeparatedReturn() on invalid code
check("int main() {\n"
" return 0\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("", errout.str());
// #4943 take care of C++11 initializer lists
@ -6667,7 +6667,7 @@ private:
" { \"2\" },\n"
" { \"3\" }\n"
" };\n"
"}", NULL, false, false, false, false);
"}", NULL, true, false, false, false);
ASSERT_EQUALS("", errout.str());
}