Fix FP in lifetime anlaysis: Dont decay std array
This will fix FP with: ```cpp std::array<char, 1> f() { std::array<char, 1> x; return x; } ```
This commit is contained in:
parent
229c45e7f8
commit
67dd822910
|
@ -2840,7 +2840,7 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
|
||||||
const Variable * var = getLifetimeVariable(tok, errorPath);
|
const Variable * var = getLifetimeVariable(tok, errorPath);
|
||||||
if (!var)
|
if (!var)
|
||||||
continue;
|
continue;
|
||||||
if (var->isArray() && !var->isArgument() && tok->astParent() &&
|
if (var->isArray() && !var->isStlType() && !var->isArgument() && tok->astParent() &&
|
||||||
(astIsPointer(tok->astParent()) || Token::Match(tok->astParent(), "%assign%|return"))) {
|
(astIsPointer(tok->astParent()) || Token::Match(tok->astParent(), "%assign%|return"))) {
|
||||||
errorPath.emplace_back(tok, "Array decayed to pointer here.");
|
errorPath.emplace_back(tok, "Array decayed to pointer here.");
|
||||||
|
|
||||||
|
|
|
@ -1510,11 +1510,18 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" struct b {\n"
|
" struct b {\n"
|
||||||
" uint32_t f[6];\n"
|
" uint32_t f[6];\n"
|
||||||
" } d;\n"
|
" } d;\n"
|
||||||
" uint32_t *a = d.f;\n"
|
" uint32_t *a = d.f;\n"
|
||||||
|
=======
|
||||||
|
// Dont decay std::array
|
||||||
|
check("std::array<char, 1> f() {\n"
|
||||||
|
" std::array<char, 1> x;\n"
|
||||||
|
" return x;\n"
|
||||||
|
>>>>>>> 52f00b8c88aecaa064f1acbebbe59331f08f09fc
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue