parent
955d6d8fc6
commit
aae810dd2c
|
@ -2426,7 +2426,9 @@ void CheckOther::checkDuplicateExpression()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (styleEnabled && tok->astOperand1() && tok->astOperand2() && tok->str() == ":" && tok->astParent() && tok->astParent()->str() == "?") {
|
} else if (styleEnabled && tok->astOperand1() && tok->astOperand2() && tok->str() == ":" && tok->astParent() && tok->astParent()->str() == "?") {
|
||||||
if (!isVariableChanged(tok->astParent(), /*indirect*/ 0, mSettings, mTokenizer->isCPP()) && !tok->astOperand1()->values().empty() && !tok->astOperand2()->values().empty() && isEqualKnownValue(tok->astOperand1(), tok->astOperand2()))
|
if (!tok->astOperand1()->values().empty() && !tok->astOperand2()->values().empty() && isEqualKnownValue(tok->astOperand1(), tok->astOperand2()) &&
|
||||||
|
!isVariableChanged(tok->astParent(), /*indirect*/ 0, mSettings, mTokenizer->isCPP()) &&
|
||||||
|
isConstStatement(tok->astOperand1(), mTokenizer->isCPP()) && isConstStatement(tok->astOperand2(), mTokenizer->isCPP()))
|
||||||
duplicateValueTernaryError(tok);
|
duplicateValueTernaryError(tok);
|
||||||
else if (isSameExpression(mTokenizer->isCPP(), true, tok->astOperand1(), tok->astOperand2(), mSettings->library, false, true, &errorPath))
|
else if (isSameExpression(mTokenizer->isCPP(), true, tok->astOperand1(), tok->astOperand2(), mSettings->library, false, true, &errorPath))
|
||||||
duplicateExpressionTernaryError(tok, errorPath);
|
duplicateExpressionTernaryError(tok, errorPath);
|
||||||
|
|
|
@ -5863,6 +5863,13 @@ private:
|
||||||
" ++x;\n"
|
" ++x;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("struct S { int a, b; };\n" // #10107
|
||||||
|
"S f(bool x, S s) {\n"
|
||||||
|
" (x) ? f.a = 42 : f.b = 42;\n"
|
||||||
|
" return f;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateExpressionTemplate() {
|
void duplicateExpressionTemplate() {
|
||||||
|
|
Loading…
Reference in New Issue