diff --git a/test/cli/fuzz-crash_c/crash-3be27d29a1cc703716c646e3cfdf21cc896654fa b/test/cli/fuzz-crash_c/crash-3be27d29a1cc703716c646e3cfdf21cc896654fa new file mode 100644 index 00000000000..e999e558f64 --- /dev/null +++ b/test/cli/fuzz-crash_c/crash-3be27d29a1cc703716c646e3cfdf21cc896654fa @@ -0,0 +1 @@ +i(){!:!=!!?:1} diff --git a/test/testclass.cpp b/test/testclass.cpp index 37dd28647a0..96344e4b5f9 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -7028,6 +7028,18 @@ class TestClass : public TestFixture { " }\n" "};\n"); ASSERT_EQUALS("", errout_str()); + + checkConst("struct A {\n" // #9981 + " int a = 0;\n" + " auto operator[](int x) -> int& {\n" + " a = 1;\n" + " return a;\n" + " }\n" + " int f() {\n" + " return (*this)[0];\n" + " }\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); } void const102() { diff --git a/test/testother.cpp b/test/testother.cpp index 951a9737f16..62824c16b36 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12999,6 +12999,16 @@ class TestOther : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:4:9]: (warning) Access of moved variable 'p'. [accessMoved]\n" "[test.cpp:5:9]: (warning) Access of moved variable 'p'. [accessMoved]\n", errout_str()); + + check("void h(std::unique_ptr);\n" // #12436 + "void g(int);\n" + "void f() {\n" + " std::unique_ptr p = std::make_unique(5);\n" + " int* w = p.get();\n" + " h(std::move(p));\n" + " g(*w);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:10]: (style) Variable 'w' can be declared as pointer to const [constVariablePointer]\n", errout_str()); } void moveAndAddressOf() { diff --git a/test/teststl.cpp b/test/teststl.cpp index d902bfa17ba..3297915ce68 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -7078,6 +7078,18 @@ class TestStl : public TestFixture { dinit(CheckOptions, $.inconclusive = true)); ASSERT_EQUALS("", errout_str()); + check("template\n" // #11583 + "int g() { return 0; }\n" + "void f() {\n" + " std::vector v(1);\n" + " auto itr = v.begin() + g();\n" + " std::vector v2(itr, v.end());\n" + " v.erase(itr, v.end());\n" + " v.push_back(v2.size());\n" + "}\n", + dinit(CheckOptions, $.inconclusive = true)); + ASSERT_EQUALS("", errout_str()); + // #13410 check("int f(std::vector& v) {\n" " const int* i = &*v.cbegin();\n"