unittests: removed not needed '\n' at the end of testcases.
This commit is contained in:
parent
7c0905cd4e
commit
54d398c7dd
|
@ -63,7 +63,7 @@ private:
|
||||||
check("void foo()\n"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" a = p;\n"
|
" a = p;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,28 +72,28 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" int a = p;\n"
|
" int a = p;\n"
|
||||||
" return a + 4;\n"
|
" return a + 4;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("int foo(int p[])\n"
|
check("int foo(int p[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int a = p;\n"
|
" int a = p;\n"
|
||||||
" return a + 4;\n"
|
" return a + 4;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("int foo(int p[])\n"
|
check("int foo(int p[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int *a = p;\n"
|
" int *a = p;\n"
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int *p = x;\n"
|
" int *p = x;\n"
|
||||||
" *p = 0;\n"
|
" *p = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("int f(const char *p) {\n" // #4659
|
check("int f(const char *p) {\n" // #4659
|
||||||
|
@ -106,7 +106,7 @@ private:
|
||||||
check("struct Foo { int *p };\n"
|
check("struct Foo { int *p };\n"
|
||||||
"void f(struct Foo *foo) {\n"
|
"void f(struct Foo *foo) {\n"
|
||||||
" int i = foo->p;\n"
|
" int i = foo->p;\n"
|
||||||
"}\n");
|
"}");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", "", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", "", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ private:
|
||||||
// Ticket #2892
|
// Ticket #2892
|
||||||
check("void foo(int *p) {\n"
|
check("void foo(int *p) {\n"
|
||||||
" int a = (p != NULL);\n"
|
" int a = (p != NULL);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,62 +123,62 @@ private:
|
||||||
check("void foo(int *p) {\n"
|
check("void foo(int *p) {\n"
|
||||||
" int x = 10;\n"
|
" int x = 10;\n"
|
||||||
" int *a = p + x;\n"
|
" int *a = p + x;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void foo(int *p) {\n"
|
check("void foo(int *p) {\n"
|
||||||
" int x = 10;\n"
|
" int x = 10;\n"
|
||||||
" int *a = x + p;\n"
|
" int *a = x + p;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void foo(int *p) {\n"
|
check("void foo(int *p) {\n"
|
||||||
" int x = 10;\n"
|
" int x = 10;\n"
|
||||||
" int *a = x * x;\n"
|
" int *a = x * x;\n"
|
||||||
"}\n");
|
"}");
|
||||||
TODO_ASSERT_EQUALS("error", "", errout.str());
|
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||||
|
|
||||||
check("void foo(int *start, int *end) {\n"
|
check("void foo(int *start, int *end) {\n"
|
||||||
" int len;\n"
|
" int len;\n"
|
||||||
" int len = end + 10 - start;\n"
|
" int len = end + 10 - start;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void returnIssues() {
|
void returnIssues() {
|
||||||
check("void* foo(int i) {\n"
|
check("void* foo(int i) {\n"
|
||||||
" return i;\n"
|
" return i;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an integer in a function with pointer return type is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an integer in a function with pointer return type is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("void* foo(int* i) {\n"
|
check("void* foo(int* i) {\n"
|
||||||
" return i;\n"
|
" return i;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void* foo() {\n"
|
check("void* foo() {\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("int foo(int i) {\n"
|
check("int foo(int i) {\n"
|
||||||
" return i;\n"
|
" return i;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("int foo(char* c) {\n"
|
check("int foo(char* c) {\n"
|
||||||
" return c;\n"
|
" return c;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("int foo(char* c) {\n"
|
check("int foo(char* c) {\n"
|
||||||
" return 1+c;\n"
|
" return 1+c;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout.str());
|
||||||
|
|
||||||
check("std::string foo(char* c) {\n"
|
check("std::string foo(char* c) {\n"
|
||||||
" return c;\n"
|
" return c;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("int foo(char *a, char *b) {\n" // #4486
|
check("int foo(char *a, char *b) {\n" // #4486
|
||||||
|
|
|
@ -65,14 +65,14 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" int y = x & 4;\n"
|
" int y = x & 4;\n"
|
||||||
" if (y == 3);\n"
|
" if (y == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int y = x & 4;\n"
|
" int y = x & 4;\n"
|
||||||
" if (y != 3);\n"
|
" if (y != 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Mismatching assignment and comparison, comparison 'y!=3' is always true.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Mismatching assignment and comparison, comparison 'y!=3' is always true.\n", errout.str());
|
||||||
|
|
||||||
// |
|
// |
|
||||||
|
@ -105,13 +105,13 @@ private:
|
||||||
check("void foo(int x) {\n"
|
check("void foo(int x) {\n"
|
||||||
" int y = x & 4;\n"
|
" int y = x & 4;\n"
|
||||||
" if ((y == 3) && (z == 1));\n"
|
" if ((y == 3) && (z == 1));\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x) {\n"
|
check("void foo(int x) {\n"
|
||||||
" int y = x & 4;\n"
|
" int y = x & 4;\n"
|
||||||
" if ((x==123) || ((y == 3) && (z == 1)));\n"
|
" if ((x==123) || ((y == 3) && (z == 1)));\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Mismatching assignment and comparison, comparison 'y==3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void f(int x) {\n"
|
check("void f(int x) {\n"
|
||||||
|
@ -183,52 +183,52 @@ private:
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x & 4 == 3);\n"
|
" if (x & 4 == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if ((x & 4) == 3);\n"
|
" if ((x & 4) == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x & 4 != 3);\n"
|
" if (x & 4 != 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) != 0x3' is always true.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) != 0x3' is always true.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if ((x | 4) == 3);\n"
|
" if ((x | 4) == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X | 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X | 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if ((x | 4) != 3);\n"
|
" if ((x | 4) != 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X | 0x4) != 0x3' is always true.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X | 0x4) != 0x3' is always true.\n", errout.str());
|
||||||
|
|
||||||
// array
|
// array
|
||||||
check("void foo(int *x)\n"
|
check("void foo(int *x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x[0] & 4 == 3);\n"
|
" if (x[0] & 4 == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
|
|
||||||
// struct member
|
// struct member
|
||||||
check("void foo(struct X *x)\n"
|
check("void foo(struct X *x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x->y & 4 == 3);\n"
|
" if (x->y & 4 == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
|
|
||||||
// expression
|
// expression
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if ((x+2) & 4 == 3);\n"
|
" if ((x+2) & 4 == 3);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,14 +237,14 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x & 7);\n"
|
" if (x & 7);\n"
|
||||||
" else if (x == 1);\n"
|
" else if (x == 1);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (style) Expression is always false because 'else if' condition matches previous condition at line 3.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) Expression is always false because 'else if' condition matches previous condition at line 3.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x & 7);\n"
|
" if (x & 7);\n"
|
||||||
" else if (x & 1);\n"
|
" else if (x & 1);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (style) Expression is always false because 'else if' condition matches previous condition at line 3.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) Expression is always false because 'else if' condition matches previous condition at line 3.\n", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -371,7 +371,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" extern struct foo f;\n"
|
" extern struct foo f;\n"
|
||||||
" return &f;\n"
|
" return &f;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ private:
|
||||||
" abc(0, psz_title);\n"
|
" abc(0, psz_title);\n"
|
||||||
" free(psz_title);\n"
|
" free(psz_title);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS(std::string(""), errout.str());
|
ASSERT_EQUALS(std::string(""), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ private:
|
||||||
check("void f(EventPtr *eventP, ActionPtr **actionsP) {\n"
|
check("void f(EventPtr *eventP, ActionPtr **actionsP) {\n"
|
||||||
" EventPtr event = *eventP;\n"
|
" EventPtr event = *eventP;\n"
|
||||||
" *actionsP = &event->actions;\n"
|
" *actionsP = &event->actions;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ private:
|
||||||
check("static void function(unsigned long **datap) {\n"
|
check("static void function(unsigned long **datap) {\n"
|
||||||
" struct my_s *mr = global_structure_pointer;\n"
|
" struct my_s *mr = global_structure_pointer;\n"
|
||||||
" *datap = &mr->value;\n"
|
" *datap = &mr->value;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[100] = {0};\n"
|
" char str[100] = {0};\n"
|
||||||
" return str;\n"
|
" return str;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Pointer to local array variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Pointer to local array variable returned.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -444,7 +444,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[100] = {0};\n"
|
" char str[100] = {0};\n"
|
||||||
" return str;\n"
|
" return str;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Pointer to local array variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Pointer to local array variable returned.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[100] = {0};\n"
|
" char str[100] = {0};\n"
|
||||||
" return str;\n"
|
" return str;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -463,7 +463,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[100] = {0};\n"
|
" char str[100] = {0};\n"
|
||||||
" return str;\n"
|
" return str;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,21 +472,21 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" std::string s;\n"
|
" std::string s;\n"
|
||||||
" return s;\n"
|
" return s;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Reference to auto variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Reference to auto variable returned.\n", errout.str());
|
||||||
|
|
||||||
check("std::vector<int> &foo()\n"
|
check("std::vector<int> &foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" return v;\n"
|
" return v;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Reference to auto variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Reference to auto variable returned.\n", errout.str());
|
||||||
|
|
||||||
check("std::vector<int> &foo()\n"
|
check("std::vector<int> &foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" static std::vector<int> v;\n"
|
" static std::vector<int> v;\n"
|
||||||
" return v;\n"
|
" return v;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("std::string hello()\n"
|
check("std::string hello()\n"
|
||||||
|
@ -497,7 +497,7 @@ private:
|
||||||
"std::string &f()\n"
|
"std::string &f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return hello();\n"
|
" return hello();\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (error) Reference to temporary returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (error) Reference to temporary returned.\n", errout.str());
|
||||||
|
|
||||||
// make sure scope is used in function lookup
|
// make sure scope is used in function lookup
|
||||||
|
@ -572,7 +572,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" std::string s;\n"
|
" std::string s;\n"
|
||||||
" return s;\n"
|
" return s;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Reference to auto variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Reference to auto variable returned.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -582,7 +582,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" return v;\n"
|
" return v;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Reference to auto variable returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Reference to auto variable returned.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -592,7 +592,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" static std::vector<int> v;\n"
|
" static std::vector<int> v;\n"
|
||||||
" return v;\n"
|
" return v;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -605,7 +605,7 @@ private:
|
||||||
"std::string &Fred::f()\n"
|
"std::string &Fred::f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return hello();\n"
|
" return hello();\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:10]: (error) Reference to temporary returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:10]: (error) Reference to temporary returned.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
|
@ -619,7 +619,7 @@ private:
|
||||||
"std::string &Fred::f()\n"
|
"std::string &Fred::f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return hello();\n"
|
" return hello();\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:11]: (error) Reference to temporary returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:11]: (error) Reference to temporary returned.\n", errout.str());
|
||||||
|
|
||||||
check("class Bar;\n"
|
check("class Bar;\n"
|
||||||
|
@ -659,7 +659,7 @@ private:
|
||||||
" double ret = getValue();\n"
|
" double ret = getValue();\n"
|
||||||
" rd = ret;\n"
|
" rd = ret;\n"
|
||||||
" return rd;\n"
|
" return rd;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ private:
|
||||||
"double & f() {\n"
|
"double & f() {\n"
|
||||||
" double & ref = a;\n"
|
" double & ref = a;\n"
|
||||||
" return ref;\n"
|
" return ref;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,21 +736,21 @@ private:
|
||||||
check("int* foo(int y)\n"
|
check("int* foo(int y)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return &y;\n"
|
" return &y;\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Address of function parameter 'y' returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Address of function parameter 'y' returned.\n", errout.str());
|
||||||
|
|
||||||
check("int ** foo(int * y)\n"
|
check("int ** foo(int * y)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return &y;\n"
|
" return &y;\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Address of function parameter 'y' returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Address of function parameter 'y' returned.\n", errout.str());
|
||||||
|
|
||||||
check("const int * foo(const int & y)\n"
|
check("const int * foo(const int & y)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return &y;\n"
|
" return &y;\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ private:
|
||||||
" m_x[1] = 0;\n"
|
" m_x[1] = 0;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" int m_x[1];\n"
|
" int m_x[1];\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Array 'm_x[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Array 'm_x[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3788,7 +3788,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" int arr[2*BSize + 2];\n"
|
" int arr[2*BSize + 2];\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" unsigned char ch = 0x80;\n"
|
" unsigned char ch = 0x80;\n"
|
||||||
" buf[ch] = 0;\n"
|
" buf[ch] = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("int buf[256];\n"
|
check("int buf[256];\n"
|
||||||
|
@ -76,7 +76,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char ch = 0x80;\n"
|
" char ch = 0x80;\n"
|
||||||
" buf[ch] = 0;\n"
|
" buf[ch] = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
||||||
|
|
||||||
check("int buf[256];\n"
|
check("int buf[256];\n"
|
||||||
|
@ -84,20 +84,20 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" signed char ch = 0x80;\n"
|
" signed char ch = 0x80;\n"
|
||||||
" buf[ch] = 0;\n"
|
" buf[ch] = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
||||||
|
|
||||||
check("int buf[256];\n"
|
check("int buf[256];\n"
|
||||||
"void foo(char ch)\n"
|
"void foo(char ch)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" buf[ch] = 0;\n"
|
" buf[ch] = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (warning) Signed 'char' type used as array index.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(const char str[])\n"
|
check("void foo(const char str[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" map[str] = 0;\n"
|
" map[str] = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ private:
|
||||||
" int result = 0;\n"
|
" int result = 0;\n"
|
||||||
" char ch;\n"
|
" char ch;\n"
|
||||||
" result = a | ch;\n"
|
" result = a | ch;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,14 +149,14 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char ch;\n"
|
" char ch;\n"
|
||||||
" func(&ch);\n"
|
" func(&ch);\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitop3() {
|
void bitop3() {
|
||||||
check("void f(int& i, char& c) {\n"
|
check("void f(int& i, char& c) {\n"
|
||||||
" i &= c;\n"
|
" i &= c;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char c;\n"
|
" char c;\n"
|
||||||
" return &c;\n"
|
" return &c;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char c;\n"
|
" char c;\n"
|
||||||
" c = c & 0x123;\n"
|
" c = c & 0x123;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char c;\n"
|
" char c;\n"
|
||||||
" int i = c & 0x03;\n"
|
" int i = c & 0x03;\n"
|
||||||
"}\n");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -166,21 +166,21 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str());
|
||||||
|
|
||||||
check("struct Fred\n"
|
check("struct Fred\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ private:
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() : i(0) { }\n"
|
" Fred() : i(0) { }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -199,7 +199,7 @@ private:
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() { i = 0; }\n"
|
" Fred() { i = 0; }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -207,14 +207,14 @@ private:
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() { }\n"
|
" Fred() { }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
|
||||||
|
|
||||||
check("struct Fred\n"
|
check("struct Fred\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" Fred() { }\n"
|
" Fred() { }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,28 +382,28 @@ private:
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() noexcept;\n"
|
" Fred() noexcept;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() noexcept(true);\n"
|
" Fred() noexcept(true);\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() noexcept { x = 0; }\n"
|
" Fred() noexcept { x = 0; }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred {\n"
|
check("class Fred {\n"
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() noexcept(true) { x = 0; }\n"
|
" Fred() noexcept(true) { x = 0; }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ private:
|
||||||
" Fred()\n"
|
" Fred()\n"
|
||||||
" { this->i = 0; }\n"
|
" { this->i = 0; }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ private:
|
||||||
" i = 1;\n"
|
" i = 1;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ private:
|
||||||
" Fred() { i = 0; }\n"
|
" Fred() { i = 0; }\n"
|
||||||
" void operator=(const Fred &fred) { }\n"
|
" void operator=(const Fred &fred) { }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ private:
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" void Init() { i = 0; }\n"
|
" void Init() { i = 0; }\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" return *this\n"
|
" return *this\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -528,7 +528,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" return *this\n"
|
" return *this\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -543,7 +543,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" return *this\n"
|
" return *this\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='.\n", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -558,7 +558,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" return *this\n"
|
" return *this\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ private:
|
||||||
" Fred(rhs).swap(*this);\n"
|
" Fred(rhs).swap(*this);\n"
|
||||||
" return *this;\n"
|
" return *this;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ private:
|
||||||
" int b;\n"
|
" int b;\n"
|
||||||
" Fred() { b = 0; }\n"
|
" Fred() { b = 0; }\n"
|
||||||
" };\n"
|
" };\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ private:
|
||||||
" int b;\n"
|
" int b;\n"
|
||||||
" Fred() { b = 0; }\n"
|
" Fred() { b = 0; }\n"
|
||||||
" };\n"
|
" };\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ private:
|
||||||
" int b;\n"
|
" int b;\n"
|
||||||
" Fred() { b = 0; }\n"
|
" Fred() { b = 0; }\n"
|
||||||
" };\n"
|
" };\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ private:
|
||||||
" Fred() { b = 0; }\n"
|
" Fred() { b = 0; }\n"
|
||||||
" };\n"
|
" };\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ private:
|
||||||
" Fred() { }\n"
|
" Fred() { }\n"
|
||||||
" };\n"
|
" };\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::a' is not initialized in the constructor.\n"
|
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::a' is not initialized in the constructor.\n"
|
||||||
"[test.cpp:16]: (warning) Member variable 'Fred::b' is not initialized in the constructor.\n", errout.str());
|
"[test.cpp:16]: (warning) Member variable 'Fred::b' is not initialized in the constructor.\n", errout.str());
|
||||||
|
@ -700,7 +700,7 @@ private:
|
||||||
"c::c()\n"
|
"c::c()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" m_iMyInt1 = m_iMyInt2 = 0;\n"
|
" m_iMyInt1 = m_iMyInt2 = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@ private:
|
||||||
"void c::InitInt()\n"
|
"void c::InitInt()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" m_iMyInt = 0;\n"
|
" m_iMyInt = 0;\n"
|
||||||
"}\n");
|
"}");
|
||||||
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ private:
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() { }\n"
|
" Fred() { }\n"
|
||||||
" static void *p;\n"
|
" static void *p;\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ private:
|
||||||
" {\n"
|
" {\n"
|
||||||
" U.a = 0;\n"
|
" U.a = 0;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class Fred\n"
|
check("class Fred\n"
|
||||||
|
@ -807,7 +807,7 @@ private:
|
||||||
" Fred()\n"
|
" Fred()\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Fred::U' is not initialized in the constructor.\n", "", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Fred::U' is not initialized in the constructor.\n", "", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ private:
|
||||||
" A(){}\n"
|
" A(){}\n"
|
||||||
" A(const A&){}\n"
|
" A(const A&){}\n"
|
||||||
" const A& operator=(const A&){return *this;}\n"
|
" const A& operator=(const A&){return *this;}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class B\n"
|
check("class B\n"
|
||||||
|
@ -1029,7 +1029,7 @@ private:
|
||||||
" A(){}\n"
|
" A(){}\n"
|
||||||
" A(const A&){}\n"
|
" A(const A&){}\n"
|
||||||
" const A& operator=(const A&){return *this;}\n"
|
" const A& operator=(const A&){return *this;}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:12]: (warning) Member variable 'A::m_SemVar' is not initialized in the constructor.\n"
|
ASSERT_EQUALS("[test.cpp:12]: (warning) Member variable 'A::m_SemVar' is not initialized in the constructor.\n"
|
||||||
"[test.cpp:13]: (warning) Member variable 'A::m_SemVar' is not assigned a value in 'A::operator='.\n", errout.str());
|
"[test.cpp:13]: (warning) Member variable 'A::m_SemVar' is not assigned a value in 'A::operator='.\n", errout.str());
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ private:
|
||||||
" A(){}\n"
|
" A(){}\n"
|
||||||
" A(const A&){}\n"
|
" A(const A&){}\n"
|
||||||
" const A& operator=(const A&){return *this;}\n"
|
" const A& operator=(const A&){return *this;}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,7 +1057,7 @@ private:
|
||||||
" A(){}\n"
|
" A(){}\n"
|
||||||
" A(const A&){}\n"
|
" A(const A&){}\n"
|
||||||
" const A& operator=(const A&){return *this;}\n"
|
" const A& operator=(const A&){return *this;}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class B\n"
|
check("class B\n"
|
||||||
|
@ -1073,7 +1073,7 @@ private:
|
||||||
" A(){}\n"
|
" A(){}\n"
|
||||||
" A(const A&){}\n"
|
" A(const A&){}\n"
|
||||||
" const A& operator=(const A&){return *this;}\n"
|
" const A& operator=(const A&){return *this;}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:12]: (warning) Member variable 'A::m_SemVar' is not initialized in the constructor.\n"
|
ASSERT_EQUALS("[test.cpp:12]: (warning) Member variable 'A::m_SemVar' is not initialized in the constructor.\n"
|
||||||
"[test.cpp:13]: (warning) Member variable 'A::m_SemVar' is not assigned a value in 'A::operator='.\n", errout.str());
|
"[test.cpp:13]: (warning) Member variable 'A::m_SemVar' is not assigned a value in 'A::operator='.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1102,7 @@ private:
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" Fred() : var(0) {}\n"
|
" Fred() : var(0) {}\n"
|
||||||
" ~Fred() {}\n"
|
" ~Fred() {}\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1110,7 +1110,7 @@ private:
|
||||||
check("class something {\n"
|
check("class something {\n"
|
||||||
" int * ( something :: * process()) () { return 0; }\n"
|
" int * ( something :: * process()) () { return 0; }\n"
|
||||||
" something() { process(); }\n"
|
" something() { process(); }\n"
|
||||||
"};\n");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue