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
check("void f(unsigned b, int len, unsigned char rem) {\n"// #10773
@@ -235,7 +232,7 @@ class TestType : public TestFixture {
235
232
" if (bits == 512)\n"
236
233
" len -= 8;\n"
237
234
" }\n"
238
-
"}\n");
235
+
"}\n", &settings0);
239
236
ASSERT_EQUALS("", errout.str());
240
237
}
241
238
@@ -282,12 +279,13 @@ class TestType : public TestFixture {
282
279
}
283
280
284
281
voidsignConversion() {
282
+
Settings settings0;
285
283
Settings settings;
286
284
PLATFORM(settings, Settings::Unix64);
287
-
check("x = -4 * (unsigned)y;");
285
+
check("x = -4 * (unsigned)y;", &settings0);
288
286
ASSERT_EQUALS("[test.cpp:1]: (warning) Expression '-4' has a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n", errout.str());
289
287
290
-
check("x = (unsigned)y * -4;");
288
+
check("x = (unsigned)y * -4;", &settings0);
291
289
ASSERT_EQUALS("[test.cpp:1]: (warning) Expression '-4' has a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n", errout.str());
292
290
293
291
check("unsigned int dostuff(int x) {\n"// x is signed
@@ -299,35 +297,35 @@ class TestType : public TestFixture {
299
297
check("unsigned int f1(signed int x, unsigned int y) {"// x is signed
300
298
" return x * y;\n"
301
299
"}\n"
302
-
"void f2() { f1(-4,4); }");
300
+
"void f2() { f1(-4,4); }", &settings0);
303
301
ASSERT_EQUALS(
304
302
"[test.cpp:1]: (warning) Expression 'x' can have a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n",
305
303
errout.str());
306
304
307
305
check("unsigned int f1(int x) {"
308
306
" return x * 5U;\n"
309
307
"}\n"
310
-
"void f2() { f1(-4); }");
308
+
"void f2() { f1(-4); }", &settings0);
311
309
ASSERT_EQUALS(
312
310
"[test.cpp:1]: (warning) Expression 'x' can have a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n",
313
311
errout.str());
314
312
315
313
check("unsigned int f1(int x) {"// #6168: FP for inner calculation
316
314
" return 5U * (1234 - x);\n"// <- signed subtraction, x is not sign converted
317
315
"}\n"
318
-
"void f2() { f1(-4); }");
316
+
"void f2() { f1(-4); }", &settings0);
319
317
ASSERT_EQUALS("", errout.str());
320
318
321
319
// Don't warn for + and -
322
320
check("void f1(int x) {"
323
321
" a = x + 5U;\n"
324
322
"}\n"
325
-
"void f2() { f1(-4); }");
323
+
"void f2() { f1(-4); }", &settings0);
326
324
ASSERT_EQUALS("", errout.str());
327
325
328
326
check("size_t foo(size_t x) {\n"
329
327
" return -2 * x;\n"
330
-
"}");
328
+
"}", &settings0);
331
329
ASSERT_EQUALS("[test.cpp:2]: (warning) Expression '-2' has a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n", errout.str());
332
330
}
333
331
@@ -390,42 +388,43 @@ class TestType : public TestFixture {
0 commit comments