Fix 11295: Regression FP: knownConditionTrueFalse (#4443)
This commit is contained in:
parent
3d10e67b3d
commit
016793f258
|
@ -1494,7 +1494,9 @@ void CheckCondition::alwaysTrueFalse()
|
|||
continue;
|
||||
if (!isUsedAsBool(tok))
|
||||
continue;
|
||||
if (Token::simpleMatch(tok->astParent(), "return") && Token::Match(tok, ".|%var%|%assign%"))
|
||||
if (Token::simpleMatch(condition, "return") && Token::Match(tok, "%assign%"))
|
||||
continue;
|
||||
if (Token::simpleMatch(tok->astParent(), "return") && Token::Match(tok, ".|%var%"))
|
||||
continue;
|
||||
if (Token::Match(tok, "%num%|%bool%|%char%"))
|
||||
continue;
|
||||
|
|
|
@ -4341,6 +4341,13 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'f()' is always true\n"
|
||||
"[test.cpp:4]: (style) Condition 'f()==3' is always true\n",
|
||||
errout.str());
|
||||
|
||||
check("int f() {\n"
|
||||
" const char *n;\n"
|
||||
" return((n=42) &&\n"
|
||||
" *n == 'A');\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueSymbolic()
|
||||
|
|
Loading…
Reference in New Issue