2020#include " checknullpointer.h"
2121#include " testsuite.h"
2222#include < sstream>
23+ #include < tinyxml2.h>
2324
2425extern std::ostringstream errout;
2526
@@ -32,9 +33,19 @@ class TestNullPointer : public TestFixture {
3233 Settings settings;
3334
3435 void run () {
35- // Load std.cfg library file
36- // TODO: This will be removed. The std.cfg is tested with the cfg testing.
37- LOAD_LIB_2 (settings.library , " std.cfg" );
36+ // Load std.cfg configuration
37+ {
38+ const char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
39+ " <def>\n "
40+ " <function name=\" strcpy\" >\n "
41+ " <arg nr=\" 1\" ><not-null/></arg>\n "
42+ " <arg nr=\" 2\" ><not-null/></arg>\n "
43+ " </function>\n "
44+ " </def>" ;
45+ tinyxml2::XMLDocument doc;
46+ doc.Parse (xmldata, sizeof (xmldata));
47+ settings.library .load (doc);
48+ }
3849
3950 TEST_CASE (nullpointerAfterLoop);
4051 TEST_CASE (nullpointer1);
@@ -49,7 +60,6 @@ class TestNullPointer : public TestFixture {
4960 TEST_CASE (nullpointer10);
5061 TEST_CASE (nullpointer11); // ticket #2812
5162 TEST_CASE (nullpointer12); // ticket #2470
52- TEST_CASE (nullpointer14);
5363 TEST_CASE (nullpointer15); // #3560 (fp: return p ? f(*p) : f(0))
5464 TEST_CASE (nullpointer16); // #3591
5565 TEST_CASE (nullpointer17); // #3567
@@ -61,7 +71,6 @@ class TestNullPointer : public TestFixture {
6171 TEST_CASE (nullpointer24); // #5082 fp: chained assignment
6272 TEST_CASE (nullpointer25); // #5061
6373 TEST_CASE (nullpointer26); // #3589
64- TEST_CASE (nullpointer27); // #6014
6574 TEST_CASE (nullpointer_addressOf); // address of
6675 TEST_CASE (nullpointerSwitch); // #2626
6776 TEST_CASE (nullpointer_cast); // #4692
@@ -1154,29 +1163,6 @@ class TestNullPointer : public TestFixture {
11541163 ASSERT_EQUALS (" " , errout.str ());
11551164 }
11561165
1157- void nullpointer14 () {
1158- check (" void foo()\n "
1159- " {\n "
1160- " strcpy(bar, 0);\n "
1161- " }" );
1162- ASSERT_EQUALS (" [test.cpp:3]: (error) Null pointer dereference\n " , errout.str ());
1163-
1164- check (" void foo()\n "
1165- " {\n "
1166- " memcmp(bar(xyz()), 0, 123);\n "
1167- " }" );
1168- ASSERT_EQUALS (" [test.cpp:3]: (error) Null pointer dereference\n " , errout.str ());
1169-
1170- check (" void foo(const char *s)\n "
1171- " {\n "
1172- " char *p = malloc(100);\n "
1173- " frexp(1.0, p);\n "
1174- " char *q = 0;\n "
1175- " frexp(1.0, q);\n "
1176- " }" );
1177- ASSERT_EQUALS (" [test.cpp:6]: (error) Possible null pointer dereference: q\n " , errout.str ());
1178- }
1179-
11801166 void nullpointer15 () { // #3560
11811167 check (" void f() {\n "
11821168 " char *p = 0;\n "
@@ -1303,36 +1289,6 @@ class TestNullPointer : public TestFixture {
13031289 ASSERT_EQUALS (" " , errout.str ());
13041290 }
13051291
1306- void nullpointer27 () { // #6014
1307- check (" void fgetpos(int x, int y);\n "
1308- " void foo() {\n "
1309- " fgetpos(0, x);\n "
1310- " fgetpos(x, 0);\n "
1311- " }" );
1312- ASSERT_EQUALS (" " , errout.str ());
1313-
1314- check (" void fgetpos(void* x, int y);\n "
1315- " void foo() {\n "
1316- " fgetpos(0, x);\n "
1317- " fgetpos(x, 0);\n "
1318- " }" );
1319- ASSERT_EQUALS (" [test.cpp:3]: (error) Null pointer dereference\n " , errout.str ());
1320-
1321- check (" void fgetpos(int x, void* y);\n "
1322- " void foo() {\n "
1323- " fgetpos(0, x);\n "
1324- " fgetpos(x, 0);\n "
1325- " }" );
1326- ASSERT_EQUALS (" [test.cpp:4]: (error) Null pointer dereference\n " , errout.str ());
1327-
1328- check (" void foo() {\n "
1329- " fgetpos(0, x);\n "
1330- " fgetpos(x, 0);\n "
1331- " }" );
1332- ASSERT_EQUALS (" [test.cpp:2]: (error) Null pointer dereference\n "
1333- " [test.cpp:3]: (error) Null pointer dereference\n " , errout.str ());
1334- }
1335-
13361292 void nullpointer_addressOf () { // address of
13371293 check (" void f() {\n "
13381294 " struct X *x = 0;\n "
0 commit comments