Skip to content

Commit

Permalink
Update testother.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Nov 26, 2024
1 parent 5bf617b commit 2af55d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,23 @@ class TestOther : public TestFixture {
" return g(a, s.x);\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("struct S { std::vector<int> v; };\n" // #13317
"struct T { S s; };\n"
"int f(S& s) {\n"
" for (std::vector<int>::const_iterator it = s.v.cbegin(); it != s.v.cend(); ++it) {}\n"
" return *s.v.cbegin();\n"
"}\n"
"int f(T& t) {\n"
" return *t.s.v.cbegin();\n"
"}\n"
"int f(std::vector<int>& v) {\n"
" return *v.cbegin();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (style) Parameter 's' can be declared as reference to const\n"
"[test.cpp:7]: (style) Parameter 't' can be declared as reference to const\n"
"[test.cpp:10]: (style) Parameter 'v' can be declared as reference to const\n",
errout_str());
}

void constParameterCallback() {
Expand Down

0 comments on commit 2af55d2

Please sign in to comment.