You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -83,28 +84,28 @@ class Test64BitPortability : public TestFixture {
83
84
" int a = p;\n"
84
85
" return a + 4;\n"
85
86
"}");
86
-
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout_str());
87
+
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
87
88
88
89
check("int foo(int p[])\n"
89
90
"{\n"
90
91
" int a = p;\n"
91
92
" return a + 4;\n"
92
93
"}");
93
-
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout_str());
94
+
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
94
95
95
96
check("int foo(int p[])\n"
96
97
"{\n"
97
98
" int *a = p;\n"
98
99
" return a;\n"
99
100
"}");
100
-
ASSERT_EQUALS("[test.cpp:4]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout_str());
101
+
ASSERT_EQUALS("[test.cpp:4:5]: (portability) Returning an address value in a function with integer return type is not portable. [CastAddressToIntegerAtReturn]\n", errout_str());
101
102
102
103
check("void foo(int x)\n"
103
104
"{\n"
104
105
" int *p = x;\n"
105
106
" *p = 0;\n"
106
107
"}");
107
-
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n", errout_str());
108
+
ASSERT_EQUALS("[test.cpp:3:12]: (portability) Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]\n", errout_str());
108
109
109
110
check("int f(const char *p) {\n"// #4659
110
111
" return 6 + p[2] * 256;\n"
@@ -169,7 +170,7 @@ class Test64BitPortability : public TestFixture {
169
170
"void f(struct Foo *foo) {\n"
170
171
" int i = foo->p;\n"
171
172
"}");
172
-
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout_str());
173
+
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
173
174
174
175
check("struct S {\n"// #10145
175
176
" enum class E { e1, e2 };\n"
@@ -208,7 +209,7 @@ class Test64BitPortability : public TestFixture {
208
209
" int x = 10;\n"
209
210
" int *a = x * x;\n"
210
211
"}");
211
-
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n", errout_str());
212
+
ASSERT_EQUALS("[test.cpp:3:12]: (portability) Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]\n", errout_str());
212
213
213
214
check("void foo(int *start, int *end) {\n"
214
215
" int len;\n"
@@ -221,7 +222,7 @@ class Test64BitPortability : public TestFixture {
221
222
check("void* foo(int i) {\n"
222
223
" return i;\n"
223
224
"}");
224
-
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an integer in a function with pointer return type is not portable.\n", errout_str());
225
+
ASSERT_EQUALS("[test.cpp:2:5]: (portability) Returning an integer in a function with pointer return type is not portable. [CastIntegerToAddressAtReturn]\n", errout_str());
225
226
226
227
check("void* foo(int* i) {\n"
227
228
" return i;\n"
@@ -248,12 +249,12 @@ class Test64BitPortability : public TestFixture {
248
249
check("int foo(char* c) {\n"
249
250
" return c;\n"
250
251
"}");
251
-
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout_str());
252
+
ASSERT_EQUALS("[test.cpp:2:5]: (portability) Returning an address value in a function with integer return type is not portable. [CastAddressToIntegerAtReturn]\n", errout_str());
252
253
253
254
check("int foo(char* c) {\n"
254
255
" return 1+c;\n"
255
256
"}");
256
-
ASSERT_EQUALS("[test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n", errout_str());
257
+
ASSERT_EQUALS("[test.cpp:2:5]: (portability) Returning an address value in a function with integer return type is not portable. [CastAddressToIntegerAtReturn]\n", errout_str());
Copy file name to clipboardExpand all lines: test/testassert.cpp
+12-11Lines changed: 12 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ class TestAssert : public TestFixture {
44
44
}
45
45
46
46
voidrun() override {
47
+
mNewTemplate = true;
47
48
TEST_CASE(assignmentInAssert);
48
49
TEST_CASE(functionCallInAssert);
49
50
TEST_CASE(memberFunctionCallInAssert);
@@ -80,7 +81,7 @@ class TestAssert : public TestFixture {
80
81
" return a;\n"
81
82
"}\n"
82
83
"assert(foo() == 3);");
83
-
ASSERT_EQUALS("[test.cpp:6]: (warning) Assert statement calls a function which may have desired side effects: 'foo'.\n", errout_str());
84
+
ASSERT_EQUALS("[test.cpp:6:8]: (warning) Assert statement calls a function which may have desired side effects: 'foo'. [assertWithSideEffect]\n", errout_str());
84
85
85
86
// Ticket #4937 "false positive: Assert calls a function which may have desired side effects"
86
87
check("struct SquarePack {\n"
@@ -103,7 +104,7 @@ class TestAssert : public TestFixture {
103
104
"void foo() {\n"
104
105
" assert( !SquarePack::isRank1Or8(push2) );\n"
105
106
"}");
106
-
ASSERT_EQUALS("[test.cpp:8]: (warning) Assert statement calls a function which may have desired side effects: 'isRank1Or8'.\n", errout_str());
107
+
ASSERT_EQUALS("[test.cpp:8:25]: (warning) Assert statement calls a function which may have desired side effects: 'isRank1Or8'. [assertWithSideEffect]\n", errout_str());
107
108
108
109
check("struct SquarePack {\n"
109
110
" static bool isRank1Or8( Square *sq ) {\n"
@@ -114,7 +115,7 @@ class TestAssert : public TestFixture {
114
115
"void foo() {\n"
115
116
" assert( !SquarePack::isRank1Or8(push2) );\n"
116
117
"}");
117
-
ASSERT_EQUALS("[test.cpp:8]: (warning) Assert statement calls a function which may have desired side effects: 'isRank1Or8'.\n", errout_str());
118
+
ASSERT_EQUALS("[test.cpp:8:25]: (warning) Assert statement calls a function which may have desired side effects: 'isRank1Or8'. [assertWithSideEffect]\n", errout_str());
118
119
119
120
check("struct SquarePack {\n"
120
121
" static bool isRank1Or8( Square *sq ) {\n"
@@ -155,7 +156,7 @@ class TestAssert : public TestFixture {
155
156
"void foo(SquarePack s) {\n"
156
157
" assert( s.Foo() );\n"
157
158
"}");
158
-
ASSERT_EQUALS("[test.cpp:5]: (warning) Assert statement calls a function which may have desired side effects: 'Foo'.\n", errout_str());
159
+
ASSERT_EQUALS("[test.cpp:5:14]: (warning) Assert statement calls a function which may have desired side effects: 'Foo'. [assertWithSideEffect]\n", errout_str());
159
160
160
161
check("struct SquarePack {\n"
161
162
" int Foo() const;\n"
@@ -187,7 +188,7 @@ class TestAssert : public TestFixture {
@@ -65,7 +66,7 @@ class TestCharVar : public TestFixture {
65
66
" char ch = 0x80;\n"
66
67
" buf[ch] = 0;\n"
67
68
"}");
68
-
ASSERT_EQUALS("[test.cpp:5]: (portability) 'char' type used as array index.\n", errout_str());
69
+
ASSERT_EQUALS("[test.cpp:5:5]: (portability) 'char' type used as array index. [unknownSignCharArrayIndex]\n", errout_str());
69
70
70
71
check("int buf[256];\n"
71
72
"void foo()\n"
@@ -89,7 +90,7 @@ class TestCharVar : public TestFixture {
89
90
" char ch = 0x80;\n"
90
91
" buf[ch] = 0;\n"
91
92
"}");
92
-
ASSERT_EQUALS("[test.cpp:5]: (portability) 'char' type used as array index.\n", errout_str());
93
+
ASSERT_EQUALS("[test.cpp:5:5]: (portability) 'char' type used as array index. [unknownSignCharArrayIndex]\n", errout_str());
93
94
94
95
check("int buf[256];\n"
95
96
"void foo(signed char ch)\n"
@@ -110,7 +111,7 @@ class TestCharVar : public TestFixture {
110
111
" char ch = 0x80;"
111
112
" buf[ch] = 0;\n"
112
113
"}");
113
-
ASSERT_EQUALS("[test.cpp:3]: (portability) 'char' type used as array index.\n", errout_str());
114
+
ASSERT_EQUALS("[test.cpp:3:24]: (portability) 'char' type used as array index. [unknownSignCharArrayIndex]\n", errout_str());
114
115
115
116
check("void foo(char* buf)\n"
116
117
"{\n"
@@ -167,7 +168,7 @@ class TestCharVar : public TestFixture {
167
168
" signed char ch = -1;\n"
168
169
" *result = a | ch;\n"
169
170
"}");
170
-
ASSERT_EQUALS("[test.cpp:3]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout_str());
171
+
ASSERT_EQUALS("[test.cpp:3:17]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results. [charBitOp]\n", errout_str());
171
172
172
173
check("void foo(int *result) {\n"
173
174
" unsigned char ch = -1;\n"
@@ -186,7 +187,7 @@ class TestCharVar : public TestFixture {
186
187
" signed char ch = -1;\n"
187
188
" *result = 0x03 | ch;\n"
188
189
"}");
189
-
ASSERT_EQUALS("[test.cpp:3]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.\n", errout_str());
190
+
ASSERT_EQUALS("[test.cpp:3:20]: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results. [charBitOp]\n", errout_str());
0 commit comments