Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3947,6 +3947,22 @@ class TestAutoVariables : public TestFixture {
" f(bar);\n"
"}\n");
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() {
Expand Down
9 changes: 9 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4219,6 +4219,15 @@ class TestCondition : public TestFixture {
" if (i == 1) {}\n"
"}\n");
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()
Expand Down
10 changes: 10 additions & 0 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,16 @@ class TestUnusedVar : public TestFixture {
" auto b { RAII() };\n"
"}\n");
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
Expand Down