@@ -2362,6 +2362,9 @@ class TestOther : public TestFixture {
23622362 checkIntToPointerCast("struct S { int i; };\n" // #13886, don't crash
23632363 "int f() { return sizeof(((struct S*)0)->i); }");
23642364 ASSERT_EQUALS("", errout_str());
2365+
2366+ checkIntToPointerCast("auto p = (int*)0b10;"); // #14180
2367+ ASSERT_EQUALS("[test.cpp:1:10]: (portability) Casting non-zero binary integer literal to pointer. [intToPointerCast]\n", errout_str());
23652368 }
23662369
23672370 struct CheckInvalidPointerCastOptions
@@ -4864,6 +4867,33 @@ class TestOther : public TestFixture {
48644867 ASSERT_EQUALS("[test.cpp:1:12]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n"
48654868 "[test.cpp:1:20]: (style) Parameter 'q' can be declared as pointer to const [constParameterPointer]\n",
48664869 errout_str());
4870+
4871+ check("struct S {\n" // #14817
4872+ " explicit S(int *a) : m{ a[0], a[1] } {}\n"
4873+ " int m[2];\n"
4874+ "};"
4875+ "struct T {\n"
4876+ " explicit T(int *a) : m{ &a[0], &a[1] } {}\n"
4877+ " int* m[2];\n"
4878+ "};\n"
4879+ "struct X{ int& r1, &r2; }\n"
4880+ "int f(int* a) {\n"
4881+ " S m[2]{a[0], a[1]};\n"
4882+ " return m[0].r1 + m[1].r2;\n"
4883+ "}\n");
4884+ ASSERT_EQUALS("[test.cpp:2:21]: (style) Parameter 'a' can be declared as pointer to const [constParameterPointer]\n",
4885+ errout_str());
4886+
4887+ check("class A {\n" // #11471
4888+ "public:\n"
4889+ " A(const int& i, int) : m_i(&i) {}\n"
4890+ " const int* m_i;\n"
4891+ "};\n"
4892+ "A f(int& s) {\n"
4893+ " return A(s, 0);\n"
4894+ "}\n");
4895+ ASSERT_EQUALS("[test.cpp:6:10]: (style) Parameter 's' can be declared as reference to const [constParameterReference]\n",
4896+ errout_str());
48674897 }
48684898
48694899 void constArray() {
0 commit comments