Fix ctuuninitvar false positive for struct that is partly initialized
This commit is contained in:
parent
322a1a5e8c
commit
a4d2178f3c
|
@ -402,6 +402,8 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer)
|
|||
argtok = addr ? addr : isReferenceArg(argtok);
|
||||
if (!argtok || argtok->values().size() != 1U)
|
||||
continue;
|
||||
if (argtok->variable() && argtok->variable()->isClass())
|
||||
continue;
|
||||
|
||||
const ValueFlow::Value &v = argtok->values().front();
|
||||
if (v.valueType == ValueFlow::Value::ValueType::UNINIT && !v.isInconclusive()) {
|
||||
|
|
|
@ -6597,6 +6597,17 @@ private:
|
|||
" return n;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (error) Using argument i that points at uninitialized variable n\n", errout.str());
|
||||
|
||||
ctu("typedef struct { int type; int id; } Stem;\n"
|
||||
"void lookupStem(recodeCtx h, Stem *stem) {\n"
|
||||
" i = stem->type & STEM_VERT;\n"
|
||||
"}\n"
|
||||
"void foo() {\n"
|
||||
" Stem stem;\n"
|
||||
" stem.type = 0;\n"
|
||||
" lookupStem(h, &stem);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue