Skip to content

Commit 7f05de2

Browse files
committed
fix #13773
1 parent 08484ca commit 7f05de2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/checkother.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -2663,6 +2663,14 @@ isStaticAssert(const Settings &settings, const Token *tok)
26632663
return false;
26642664
}
26652665

2666+
static bool isSizeof(const Token *tok)
2667+
{
2668+
if (!Token::simpleMatch(tok, "("))
2669+
return false;
2670+
2671+
return Token::simpleMatch(tok->astOperand1(), "sizeof");
2672+
}
2673+
26662674
void CheckOther::checkDuplicateExpression()
26672675
{
26682676
{
@@ -2846,7 +2854,8 @@ void CheckOther::checkDuplicateExpression()
28462854
} else if (tok->astOperand1() && tok->astOperand2() && tok->str() == ":" && tok->astParent() && tok->astParent()->str() == "?") {
28472855
if (!tok->astOperand1()->values().empty() && !tok->astOperand2()->values().empty() && isEqualKnownValue(tok->astOperand1(), tok->astOperand2()) &&
28482856
!isVariableChanged(tok->astParent(), /*indirect*/ 0, *mSettings) &&
2849-
isConstStatement(tok->astOperand1(), mSettings->library) && isConstStatement(tok->astOperand2(), mSettings->library))
2857+
isConstStatement(tok->astOperand1(), mSettings->library) && isConstStatement(tok->astOperand2(), mSettings->library) &&
2858+
!isSizeof(tok->astOperand1()) && !isSizeof(tok->astOperand2()))
28502859
duplicateValueTernaryError(tok);
28512860
else if (isSameExpression(true, tok->astOperand1(), tok->astOperand2(), *mSettings, false, true, &errorPath))
28522861
duplicateExpressionTernaryError(tok, std::move(errorPath));

0 commit comments

Comments
 (0)