* Fix #11238 FP knownConditionTrueFalse with constexpr? * Modify isConstVarExpression() * Use predicate * Format * #11238: Fix regression
This commit is contained in:
parent
974e34490f
commit
bdbd84ba98
|
@ -2784,7 +2784,7 @@ bool isConstVarExpression(const Token *tok, std::function<bool(const Token*)> sk
|
|||
std::vector<const Token *> args = getArguments(tok);
|
||||
if (args.empty() && tok->previous()->function() && tok->previous()->function()->isConstexpr())
|
||||
return true;
|
||||
return std::all_of(args.begin(), args.end(), [&](const Token* t) {
|
||||
return !args.empty() && std::all_of(args.begin(), args.end(), [&](const Token* t) {
|
||||
return isConstVarExpression(t, skipPredicate);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4289,6 +4289,14 @@ private:
|
|||
" return f() == 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int g() { return -1; }\n"
|
||||
"void f() {\n"
|
||||
" if (g() == 1 && g() == -1) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'g()==1' is always false\n"
|
||||
"[test.cpp:3]: (style) Condition 'g()==-1' is always true\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueSymbolic()
|
||||
|
|
Loading…
Reference in New Issue