From 2b5cd2effcd87b70e9a38ee082c991f00f608a83 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Tue, 21 Aug 2012 20:15:04 +0200 Subject: [PATCH] Fixed G++ [-Wparentheses] warning. This also fixed #4073 (Crash on self assignment). --- lib/checkother.cpp | 2 +- test/testother.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 7eaa0decf..4581d6937 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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() diff --git a/test/testother.cpp b/test/testother.cpp index d59ed0f35..d43596983 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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"