Skip to content

Commit 79ac5ad

Browse files
Add tests for #9981, #11583, #12436, #14736 (#8929)
1 parent bb715ca commit 79ac5ad

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
i(){!:!=!!?:1}

‎test/testclass.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7028,6 +7028,18 @@ class TestClass : public TestFixture {
70287028
" }\n"
70297029
"};\n");
70307030
ASSERT_EQUALS("", errout_str());
7031+
7032+
checkConst("struct A {\n" // #9981
7033+
" int a = 0;\n"
7034+
" auto operator[](int x) -> int& {\n"
7035+
" a = 1;\n"
7036+
" return a;\n"
7037+
" }\n"
7038+
" int f() {\n"
7039+
" return (*this)[0];\n"
7040+
" }\n"
7041+
"};\n");
7042+
ASSERT_EQUALS("", errout_str());
70317043
}
70327044

70337045
void const102() {

‎test/testother.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12999,6 +12999,16 @@ class TestOther : public TestFixture {
1299912999
"}\n");
1300013000
ASSERT_EQUALS("[test.cpp:4:9]: (warning) Access of moved variable 'p'. [accessMoved]\n"
1300113001
"[test.cpp:5:9]: (warning) Access of moved variable 'p'. [accessMoved]\n", errout_str());
13002+
13003+
check("void h(std::unique_ptr<int>);\n" // #12436
13004+
"void g(int);\n"
13005+
"void f() {\n"
13006+
" std::unique_ptr<int> p = std::make_unique<int>(5);\n"
13007+
" int* w = p.get();\n"
13008+
" h(std::move(p));\n"
13009+
" g(*w);\n"
13010+
"}\n");
13011+
ASSERT_EQUALS("[test.cpp:5:10]: (style) Variable 'w' can be declared as pointer to const [constVariablePointer]\n", errout_str());
1300213012
}
1300313013

1300413014
void moveAndAddressOf() {

‎test/teststl.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7078,6 +7078,18 @@ class TestStl : public TestFixture {
70787078
dinit(CheckOptions, $.inconclusive = true));
70797079
ASSERT_EQUALS("", errout_str());
70807080

7081+
check("template<typename T>\n" // #11583
7082+
"int g() { return 0; }\n"
7083+
"void f() {\n"
7084+
" std::vector<int> v(1);\n"
7085+
" auto itr = v.begin() + g<int>();\n"
7086+
" std::vector<int> v2(itr, v.end());\n"
7087+
" v.erase(itr, v.end());\n"
7088+
" v.push_back(v2.size());\n"
7089+
"}\n",
7090+
dinit(CheckOptions, $.inconclusive = true));
7091+
ASSERT_EQUALS("", errout_str());
7092+
70817093
// #13410
70827094
check("int f(std::vector<int>& v) {\n"
70837095
" const int* i = &*v.cbegin();\n"

0 commit comments

Comments
 (0)