* Add tests for #6925, #11042, #11494 * Format * Add tests for # 6561, #6619, #7475,
This commit is contained in:
parent
bf3be95046
commit
67a8ff0b27
|
@ -5968,6 +5968,27 @@ private:
|
||||||
" if (a[0]) {}\n"
|
" if (a[0]) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #6619
|
||||||
|
valueFlowUninit("void f() {\n"
|
||||||
|
" int nok, i;\n"
|
||||||
|
" for (i = 1; i < 5; i++) {\n"
|
||||||
|
" if (i == 8)\n"
|
||||||
|
" nok = 8;\n"
|
||||||
|
" }\n"
|
||||||
|
" printf(\"nok = %d\\n\", nok);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:7]: (warning) Uninitialized variable: nok\n", errout.str());
|
||||||
|
|
||||||
|
// #7475
|
||||||
|
valueFlowUninit("struct S {\n"
|
||||||
|
" int a, b, c;\n"
|
||||||
|
"} typedef s_t;\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" s_t s;\n"
|
||||||
|
" printf(\"%d\", s.a);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: s.a\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
||||||
|
|
|
@ -1640,6 +1640,14 @@ private:
|
||||||
"\n"
|
"\n"
|
||||||
"input.skip(sizeof(struct Header));");
|
"input.skip(sizeof(struct Header));");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkStructMemberUsage("struct S { int a, b, c; };\n" // #6561
|
||||||
|
"int f(FILE * fp) {\n"
|
||||||
|
" S s;\n"
|
||||||
|
" ::fread(&s, sizeof(S), 1, fp);\n"
|
||||||
|
" return s.b;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void structmember16() {
|
void structmember16() {
|
||||||
|
|
Loading…
Reference in New Issue