Skip to content

Commit c368cbb

Browse files
committed
Add tests
1 parent 4819255 commit c368cbb

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
@@ -12892,6 +12892,26 @@ class TestOther : public TestFixture {
1289212892
" friend int f() { int i = 5; return i; }\n"
1289312893
"};\n");
1289412894
ASSERT_EQUALS("", errout_str());
12895+
12896+
check("int x;\n"
12897+
"void f(int x) {}\n");
12898+
ASSERT_EQUALS("[test.cpp:1:5] -> [test.cpp:2:12]: (style) Argument 'x' shadows outer variable [shadowVariable]\n", errout_str());
12899+
12900+
check("void x() {}\n"
12901+
"void f(int x) {}\n");
12902+
ASSERT_EQUALS("[test.cpp:1:6] -> [test.cpp:2:12]: (style) Argument 'x' shadows outer function [shadowFunction]\n", errout_str());
12903+
12904+
check("struct S { int v; void func(int v); };\n"
12905+
"void S::func(int v) { this->v = v; }\n");
12906+
ASSERT_EQUALS("[test.cpp:1:16] -> [test.cpp:2:18]: (style) Argument 'v' shadows outer member [shadowMember]\n", errout_str());
12907+
12908+
check("struct S { int v; void func(void); };\n"
12909+
"void S::func() { int v = 0; }\n");
12910+
ASSERT_EQUALS("[test.cpp:1:16] -> [test.cpp:2:22]: (style) Local variable 'v' shadows outer member [shadowMember]\n", errout_str());
12911+
12912+
check("struct S { int v; explicit S(int v); };\n"
12913+
"S::S(int v) : v(v) {}\n");
12914+
ASSERT_EQUALS("", errout_str());
1289512915
}
1289612916

1289712917
void knownArgument() {

0 commit comments

Comments
 (0)