Fixed #5643 (crash on address-of-operator& in condition) as suggested by serval2412

This commit is contained in:
PKEuS 2014-04-10 19:45:24 +02:00
parent e19129a409
commit 25b1f2f541
2 changed files with 9 additions and 0 deletions

View File

@ -264,6 +264,8 @@ static bool isOverlappingCond(const Token * const cond1, const Token * const con
if (cond1->str() == "&" && cond1->astOperand1() && cond2->astOperand2()) {
const Token *expr1 = cond1->astOperand1();
const Token *num1 = cond1->astOperand2();
if (!num1) // unary operator&
return false;
if (!num1->isNumber())
std::swap(expr1,num1);
if (!num1->isNumber() || MathLib::isNegative(num1->str()))

View File

@ -218,6 +218,13 @@ private:
" if (y==1) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
// no crash on unary operator& (#5643)
check("SdrObject* ApplyGraphicToObject() {\n"
" if (&rHitObject) {}\n"
" else if (rHitObject.IsClosedObj() && !&rHitObject) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void mismatchingBitAnd() {