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
Copy file name to clipboardExpand all lines: test/test64bit.cpp
+31-31Lines changed: 31 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ class Test64BitPortability : public TestFixture {
58
58
check("using CharArray = char[16];\n"
59
59
"void f() {\n"
60
60
" CharArray foo = \"\";\n"
61
-
"}");
61
+
"}\n");
62
62
ASSERT_EQUALS("", errout_str());
63
63
64
64
check("struct T { std::vector<int>*a[2][2]; };\n"// #11560
@@ -79,7 +79,7 @@ class Test64BitPortability : public TestFixture {
79
79
check("void foo()\n"
80
80
"{\n"
81
81
" a = p;\n"
82
-
"}");
82
+
"}\n");
83
83
ASSERT_EQUALS("", errout_str());
84
84
}
85
85
@@ -88,65 +88,65 @@ class Test64BitPortability : public TestFixture {
88
88
"{\n"
89
89
" int a = p;\n"
90
90
" return a + 4;\n"
91
-
"}");
91
+
"}\n");
92
92
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
93
93
94
94
check("int foo(int p[])\n"
95
95
"{\n"
96
96
" int a = p;\n"
97
97
" return a + 4;\n"
98
-
"}");
98
+
"}\n");
99
99
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
100
100
101
101
check("int foo(int p[])\n"
102
102
"{\n"
103
103
" int *a = p;\n"
104
104
" return a;\n"
105
-
"}");
105
+
"}\n");
106
106
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());
107
107
108
108
check("void foo(int x)\n"
109
109
"{\n"
110
110
" int *p = x;\n"
111
111
" *p = 0;\n"
112
-
"}");
112
+
"}\n");
113
113
ASSERT_EQUALS("[test.cpp:3:12]: (portability) Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]\n", errout_str());
114
114
115
115
check("int f(const char *p) {\n"// #4659
116
116
" return 6 + p[2] * 256;\n"
117
-
"}");
117
+
"}\n");
118
118
ASSERT_EQUALS("", errout_str());
119
119
120
120
check("int foo(int *p) {\n"// #6096
121
121
" bool a = p;\n"
122
122
" return a;\n"
123
-
"}");
123
+
"}\n");
124
124
ASSERT_EQUALS("", errout_str());
125
125
126
126
check("std::array<int,2> f();\n"
127
127
"void g() {\n"
128
128
" std::array<int, 2> a = f();\n"
129
-
"}");
129
+
"}\n");
130
130
ASSERT_EQUALS("", errout_str());
131
131
132
132
check("std::array<int,2> f(int x);\n"
133
133
"void g(int i) {\n"
134
134
" std::array<int, 2> a = f(i);\n"
135
-
"}");
135
+
"}\n");
136
136
ASSERT_EQUALS("", errout_str());
137
137
138
138
check("typedef std::array<int, 2> Array;\n"
139
139
"Array f(int x);\n"
140
140
"void g(int i) {\n"
141
141
" Array a = f(i);\n"
142
-
"}");
142
+
"}\n");
143
143
ASSERT_EQUALS("", errout_str());
144
144
145
145
check("typedef std::array<int, 2> Array;\n"
146
146
"Array f();\n"
147
147
"void g(int i) {\n"
148
148
" Array a = f();\n"
149
-
"}");
149
+
"}\n");
150
150
ASSERT_EQUALS("", errout_str());
151
151
152
152
check("struct S {\n"// #9951
@@ -174,7 +174,7 @@ class Test64BitPortability : public TestFixture {
174
174
check("struct Foo { int *p; };\n"
175
175
"void f(struct Foo *foo) {\n"
176
176
" int i = foo->p;\n"
177
-
"}");
177
+
"}\n");
178
178
ASSERT_EQUALS("[test.cpp:3:11]: (portability) Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]\n", errout_str());
179
179
180
180
check("struct S {\n"// #10145
@@ -192,7 +192,7 @@ class Test64BitPortability : public TestFixture {
192
192
// Ticket #2892
193
193
check("void foo(int *p) {\n"
194
194
" int a = (p != NULL);\n"
195
-
"}");
195
+
"}\n");
196
196
ASSERT_EQUALS("", errout_str());
197
197
}
198
198
@@ -201,104 +201,104 @@ class Test64BitPortability : public TestFixture {
201
201
check("void foo(int *p) {\n"
202
202
" int x = 10;\n"
203
203
" int *a = p + x;\n"
204
-
"}");
204
+
"}\n");
205
205
ASSERT_EQUALS("", errout_str());
206
206
207
207
check("void foo(int *p) {\n"
208
208
" int x = 10;\n"
209
209
" int *a = x + p;\n"
210
-
"}");
210
+
"}\n");
211
211
ASSERT_EQUALS("", errout_str());
212
212
213
213
check("void foo(int *p) {\n"
214
214
" int x = 10;\n"
215
215
" int *a = x * x;\n"
216
-
"}");
216
+
"}\n");
217
217
ASSERT_EQUALS("[test.cpp:3:12]: (portability) Assigning an integer to a pointer is not portable. [AssignmentIntegerToAddress]\n", errout_str());
218
218
219
219
check("void foo(int *start, int *end) {\n"
220
220
" int len;\n"
221
221
" int len = end + 10 - start;\n"
222
-
"}");
222
+
"}\n");
223
223
ASSERT_EQUALS("", errout_str());
224
224
}
225
225
226
226
voidreturnIssues() {
227
227
check("void* foo(int i) {\n"
228
228
" return i;\n"
229
-
"}");
229
+
"}\n");
230
230
ASSERT_EQUALS("[test.cpp:2:5]: (portability) Returning an integer in a function with pointer return type is not portable. [CastIntegerToAddressAtReturn]\n", errout_str());
231
231
232
232
check("void* foo(int* i) {\n"
233
233
" return i;\n"
234
-
"}");
234
+
"}\n");
235
235
ASSERT_EQUALS("", errout_str());
236
236
237
237
check("void* foo() {\n"
238
238
" return 0;\n"
239
-
"}");
239
+
"}\n");
240
240
ASSERT_EQUALS("", errout_str());
241
241
242
242
check("int foo(int i) {\n"
243
243
" return i;\n"
244
-
"}");
244
+
"}\n");
245
245
ASSERT_EQUALS("", errout_str());
246
246
247
247
check("struct Foo {};\n"
248
248
"\n"
249
249
"int* dostuff(Foo foo) {\n"
250
250
" return foo;\n"
251
-
"}");
251
+
"}\n");
252
252
ASSERT_EQUALS("", errout_str());
253
253
254
254
check("int foo(char* c) {\n"
255
255
" return c;\n"
256
-
"}");
256
+
"}\n");
257
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());
258
258
259
259
check("int foo(char* c) {\n"
260
260
" return 1+c;\n"
261
-
"}");
261
+
"}\n");
262
262
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());
263
263
264
264
check("std::string foo(char* c) {\n"
265
265
" return c;\n"
266
-
"}");
266
+
"}\n");
267
267
ASSERT_EQUALS("", errout_str());
268
268
269
269
check("int foo(char *a, char *b) {\n"// #4486
270
270
" return a + 1 - b;\n"
271
-
"}");
271
+
"}\n");
272
272
ASSERT_EQUALS("", errout_str());
273
273
274
274
check("struct s {\n"// 4642
275
275
" int i;\n"
276
276
"};\n"
277
277
"int func(struct s *p) {\n"
278
278
" return 1 + p->i;\n"
279
-
"}");
279
+
"}\n");
280
280
ASSERT_EQUALS("", errout_str());
281
281
282
282
check("static void __iomem *f(unsigned int port_no) {\n"
283
283
" void __iomem *mmio = hpriv->mmio;\n"
284
284
" return mmio + (port_no * 0x80);\n"
285
-
"}");
285
+
"}\n");
286
286
ASSERT_EQUALS("", errout_str());
287
287
288
288
// #7247: don't check return statements in nested functions..
0 commit comments