parent
cc9c5a2768
commit
6dc606fd6a
|
@ -3947,6 +3947,22 @@ private:
|
||||||
" f(bar);\n"
|
" f(bar);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:11]: (error) Address of local auto-variable assigned to a function parameter.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:11]: (error) Address of local auto-variable assigned to a function parameter.\n", errout.str());
|
||||||
|
|
||||||
|
check("class Foo {};\n" // #10750
|
||||||
|
"struct Bar {\n"
|
||||||
|
" Foo *_foo;\n"
|
||||||
|
"};\n"
|
||||||
|
"int f(Bar *bar);\n"
|
||||||
|
"void g(Bar *bar) {\n"
|
||||||
|
" {\n"
|
||||||
|
" Foo foo;\n"
|
||||||
|
" {\n"
|
||||||
|
" bar->_foo = &foo;\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
" f(bar);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:10]: (error) Address of local auto-variable assigned to a function parameter.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void deadPointer() {
|
void deadPointer() {
|
||||||
|
|
|
@ -4219,6 +4219,15 @@ private:
|
||||||
" if (i == 1) {}\n"
|
" if (i == 1) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:20]: (style) Condition 'i==1' is always true\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:20]: (style) Condition 'i==1' is always true\n", errout.str());
|
||||||
|
|
||||||
|
check("typedef struct { bool x; } s_t;\n" // #8446
|
||||||
|
"unsigned f(bool a, bool b) {\n"
|
||||||
|
" s_t s;\n"
|
||||||
|
" const unsigned col = a ? (s.x = false) : (b = true);\n"
|
||||||
|
" if (!s.x) {}\n"
|
||||||
|
" return col;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void alwaysTrueSymbolic()
|
void alwaysTrueSymbolic()
|
||||||
|
|
|
@ -3292,6 +3292,16 @@ private:
|
||||||
" auto b { RAII() };\n"
|
" auto b { RAII() };\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage("struct RAIIWrapper {\n" // #10894
|
||||||
|
" RAIIWrapper();\n"
|
||||||
|
" ~RAIIWrapper();\n"
|
||||||
|
"};\n"
|
||||||
|
"static void foo() {\n"
|
||||||
|
" auto const guard = RAIIWrapper();\n"
|
||||||
|
" auto const& guard2 = RAIIWrapper();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localvar47() { // #6603
|
void localvar47() { // #6603
|
||||||
|
|
Loading…
Reference in New Issue