CTU: Avoid FP in else block
This commit is contained in:
parent
fb6a291370
commit
aa4f61acdf
|
@ -374,7 +374,7 @@ static bool isUnsafeFunction(const Tokenizer *tokenizer, const Settings *setting
|
|||
if (!argvar->isPointer())
|
||||
return false;
|
||||
for (const Token *tok2 = scope->bodyStart; tok2 != scope->bodyEnd; tok2 = tok2->next()) {
|
||||
if (Token::simpleMatch(tok2, ") {")) {
|
||||
if (Token::Match(tok2, ")|else {")) {
|
||||
tok2 = tok2->linkAt(1);
|
||||
if (Token::findmatch(tok2->link(), "return|throw", tok2))
|
||||
return false;
|
||||
|
|
|
@ -2741,6 +2741,17 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// else
|
||||
ctu("void dostuff(int mask, int *p) {\n"
|
||||
" if (mask == 13) ;\n"
|
||||
" else *p = 45;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void f() {\n"
|
||||
" dostuff(0, 0);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ?, &&, ||
|
||||
ctu("void dostuff(int mask, int *p) {\n"
|
||||
" x = (mask & 1) ? *p : 0;\n"
|
||||
|
|
Loading…
Reference in New Issue