diff --git a/test/testbool.cpp b/test/testbool.cpp index 006d9606a..b1e7ccdb7 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -614,10 +614,6 @@ private: "void f() { bValue++; }"); ASSERT_EQUALS("[test.cpp:2]: (style) Incrementing a variable of type 'bool' with postfix operator++ is deprecated by the C++ Standard. You should assign it the value 'true' instead.\n", errout.str()); - check("_Bool bValue = true;\n" - "void f() { bValue++; }"); - ASSERT_EQUALS("[test.cpp:2]: (style) Incrementing a variable of type 'bool' with postfix operator++ is deprecated by the C++ Standard. You should assign it the value 'true' instead.\n", errout.str()); - check("void f(bool test){\n" " test++;\n" "}"); diff --git a/test/testclass.cpp b/test/testclass.cpp index 407aa0316..3074e29a3 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -2355,12 +2355,6 @@ private: "}"); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (warning) Memory for class instance allocated with realloc(), but class provides constructors.\n", errout.str()); - checkNoMemset("struct C { C() {} };\n" - "void foo(C*& p) {\n" - " p = realloc(p, sizeof(C));\n" - "}"); - ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (warning) Memory for class instance allocated with realloc(), but class provides constructors.\n", errout.str()); - checkNoMemset("struct C { virtual void bar(); };\n" "void foo(C*& p) {\n" " p = malloc(sizeof(C));\n" @@ -3213,37 +3207,6 @@ private: ASSERT_EQUALS("", errout.str()); - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< int,vector > GetPair() {return m_pair;}\n" - "private:\n" - " pair< int,vector > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " const pair< int,vector >& GetPair() {return m_pair;}\n" - "private:\n" - " pair< int,vector > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< int,vector >& GetPair() {return m_pair;}\n" - "private:\n" - " pair< int,vector > m_pair;\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - checkConst("using namespace std;" "class A {\n" "public:\n" @@ -3302,37 +3265,6 @@ private: ASSERT_EQUALS("", errout.str()); - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< vector, vector > GetPair() {return m_pair;}\n" - "private:\n" - " pair< vector, vector > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " const pair< vector, vector >& GetPair() {return m_pair;}\n" - "private:\n" - " pair< vector, vector > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< vector, vector >& GetPair() {return m_pair;}\n" - "private:\n" - " pair< vector, vector > m_pair;\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - checkConst("class A {\n" "public:\n" @@ -3361,67 +3293,6 @@ private: "};"); ASSERT_EQUALS("", errout.str()); - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< pair < int, char > , int > GetPair() {return m_pair;}\n" - "private:\n" - " pair< pair < int, char > , int > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " const pair< pair < int, char > , int > & GetPair() {return m_pair;}\n" - "private:\n" - " pair< pair < int, char > , int > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< pair < int, char > , int > & GetPair() {return m_pair;}\n" - "private:\n" - " pair< pair < int, char > , int > m_pair;\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< int , pair < int, char > > GetPair() {return m_pair;}\n" - "private:\n" - " pair< int , pair < int, char > > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " const pair< int , pair < int, char > > & GetPair() {return m_pair;}\n" - "private:\n" - " pair< int , pair < int, char > > m_pair;\n" - "};"); - ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); - - - checkConst("using namespace std;" - "class A {\n" - "public:\n" - " A(){}\n" - " pair< int , pair < int, char > > & GetPair() {return m_pair;}\n" - "private:\n" - " pair< int , pair < int, char > > m_pair;\n" - "};"); - ASSERT_EQUALS("", errout.str()); checkConst("class A {\n" "public:\n" @@ -3497,14 +3368,6 @@ private: " const int * x;\n" "};"); ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); - - checkConst("class A {\n" - "public:\n" - " const int * const * foo() { return &x; }\n" - "private:\n" - " const int * x;\n" - "};"); - ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); } void const15() { @@ -5134,16 +4997,17 @@ private: ASSERT_EQUALS("", errout.str()); } - // A function that returns LPVOID can't be const + // A function that returns unknown types can't be const (#1579) void constLPVOID() { checkConst("class Fred {\n" - " LPVOID a() { return 0; };\n" + " UNKNOWN a() { return 0; };\n" "};"); - ASSERT_EQUALS("", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:2]: (performance, inconclusive) Technically the member function 'Fred::a' can be static.\n", "", errout.str()); // #1579 - HDC checkConst("class Fred {\n" - " HDC a() { return 0; };\n" + " foo bar;\n" + " UNKNOWN a() { return b; };\n" "};"); ASSERT_EQUALS("", errout.str()); } diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 094cd31f3..7c0d4153b 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -66,7 +66,6 @@ private: TEST_CASE(simple10); // ticket #4388 TEST_CASE(simple11); // ticket #4536 TEST_CASE(simple12); // ticket #4620 - TEST_CASE(simple13); // ticket #4617 TEST_CASE(initvar_with_this); // BUG 2190300 TEST_CASE(initvar_if); // BUG 2190290 @@ -390,36 +389,6 @@ private: ASSERT_EQUALS("", errout.str()); } - void simple13() { // ticket #4617 - check("class Fred {\n" - " int x;\n" - "public:\n" - " Fred() noexcept;\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - check("class Fred {\n" - " int x;\n" - "public:\n" - " Fred() noexcept(true);\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - check("class Fred {\n" - " int x;\n" - "public:\n" - " Fred() noexcept { x = 0; }\n" - "};"); - ASSERT_EQUALS("", errout.str()); - - check("class Fred {\n" - " int x;\n" - "public:\n" - " Fred() noexcept(true) { x = 0; }\n" - "};"); - ASSERT_EQUALS("", errout.str()); - } - void initvar_with_this() { check("struct Fred\n" "{\n" @@ -885,18 +854,6 @@ private: "};"); ASSERT_EQUALS("", errout.str()); - check("class Fred\n" - "{\n" - "private:\n" - " std::string var;\n" - "public:\n" - " Fred();\n" - " Fred(const Fred &);\n" - "};\n" - "Fred::Fred() { };\n" - "Fred::Fred(const Fred &) { };"); - ASSERT_EQUALS("", errout.str()); - check("class Fred\n" "{\n" "private:\n"