CTU: Avoid FP in code protected by &&,||,?
This commit is contained in:
parent
a520a41e64
commit
fb6a291370
|
@ -381,6 +381,10 @@ static bool isUnsafeFunction(const Tokenizer *tokenizer, const Settings *setting
|
|||
if (isVariableChanged(tok2->link(), tok2, argvar->declarationId(), false, settings, tokenizer->isCPP()))
|
||||
return false;
|
||||
}
|
||||
if (Token::Match(tok2, "%oror%|&&|?")) {
|
||||
tok2 = tok2->findExpressionStartEndTokens().second;
|
||||
continue;
|
||||
}
|
||||
if (tok2->variable() != argvar)
|
||||
continue;
|
||||
if (!isUnsafeUsage(check, tok2))
|
||||
|
|
|
@ -2740,6 +2740,16 @@ private:
|
|||
" dostuff(a, 0);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ?, &&, ||
|
||||
ctu("void dostuff(int mask, int *p) {\n"
|
||||
" x = (mask & 1) ? *p : 0;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void f() {\n"
|
||||
" dostuff(0, 0);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue