Fixed G++ [-Wparentheses] warning. This also fixed #4073 (Crash on self assignment).

This commit is contained in:
Edoardo Prezioso 2012-08-21 20:15:04 +02:00
parent 41b624230f
commit 2b5cd2effc
2 changed files with 8 additions and 1 deletions

View File

@ -871,7 +871,7 @@ void CheckOther::switchCaseFallThrough(const Token *tok)
//---------------------------------------------------------------------------
static bool isTypeWithoutSideEffects(const Tokenizer *tokenizer, const Variable* var)
{
return ((var && (!var->isClass() || var->isPointer()) || Token::simpleMatch(var->typeStartToken(), "std ::")) || !tokenizer->isCPP());
return ((var && (!var->isClass() || var->isPointer() || Token::simpleMatch(var->typeStartToken(), "std ::"))) || !tokenizer->isCPP());
}
void CheckOther::checkSelfAssignment()

View File

@ -2309,6 +2309,13 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant assignment of \"var\" to itself\n", errout.str());
// #4073 (segmentation fault)
check("void Foo::myFunc( int a )\n"
"{\n"
" if (a == 42)\n"
" a = a;\n"
"}\n");
check("void foo()\n"
"{\n"
" int x = 1;\n"