Skip to content

Commit afb0bd8

Browse files
committed
Add tests
1 parent 74dc314 commit afb0bd8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12844,6 +12844,26 @@ class TestOther : public TestFixture {
1284412844
" friend int f() { int i = 5; return i; }\n"
1284512845
"};\n");
1284612846
ASSERT_EQUALS("", errout_str());
12847+
12848+
check("int x;\n"
12849+
"void f(int x) {}\n");
12850+
ASSERT_EQUALS("[test.cpp:1:5] -> [test.cpp:2:12]: (style) Argument 'x' shadows outer variable [shadowVariable]\n", errout_str());
12851+
12852+
check("void x() {}\n"
12853+
"void f(int x) {}\n");
12854+
ASSERT_EQUALS("[test.cpp:1:6] -> [test.cpp:2:12]: (style) Argument 'x' shadows outer function [shadowFunction]\n", errout_str());
12855+
12856+
check("struct S { int v; void func(int v); };\n"
12857+
"void S::func(int v) { this->v = v; }\n");
12858+
ASSERT_EQUALS("[test.cpp:1:16] -> [test.cpp:2:18]: (style) Argument 'v' shadows outer member [shadowMember]\n", errout_str());
12859+
12860+
check("struct S { int v; void func(void); };\n"
12861+
"void S::func() { int v = 0; }\n");
12862+
ASSERT_EQUALS("[test.cpp:1:16] -> [test.cpp:2:22]: (style) Local variable 'v' shadows outer member [shadowMember]\n", errout_str());
12863+
12864+
check("struct S { int v; explicit S(int v); };\n"
12865+
"S::S(int v) : v(v) {}\n");
12866+
ASSERT_EQUALS("", errout_str());
1284712867
}
1284812868

1284912869
void knownArgument() {

0 commit comments

Comments
 (0)