Fix #10248 FP knownConditionTrueFalse static variable with direct initialization (#3922)

This commit is contained in:
chrchr-github 2022-03-22 07:24:40 +01:00 committed by GitHub
parent 18a7a805df
commit 3faff5e9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -7497,6 +7497,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
varName = varName->link()->previous();
endDecl->insertToken(";");
endDecl = endDecl->next();
endDecl->next()->isSplittedVarDeclEq(true);
endDecl->insertToken(varName->str());
continue;
}

View File

@ -5292,7 +5292,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldat
});
if (values.empty())
continue;
const bool init = vars.size() == 1 && vars.front()->nameToken() == tok->astOperand1();
const bool init = vars.size() == 1 && (vars.front()->nameToken() == tok->astOperand1() || tok->isSplittedVarDeclEq());
valueFlowForwardAssign(
tok->astOperand2(), tok->astOperand1(), vars, values, init, tokenlist, errorLogger, settings);
// Back propagate symbolic values

View File

@ -3935,7 +3935,7 @@ private:
" if (logger == nullptr)\n"
" logger = Fun;\n"
"}\n");
TODO_ASSERT_EQUALS("", "[test.cpp:5]: (style) Condition 'logger==nullptr' is always true\n", errout.str());
ASSERT_EQUALS("", errout.str());
check("void Fun();\n"
"typedef void (*Fn)();\n"