@@ -37,6 +37,7 @@ class TestNullPointer : public TestFixture {
3737
3838private:
3939 const Settings settings = settingsBuilder().library("std.cfg").severity(Severity::warning).build();
40+ const Settings settings_i = settingsBuilder(settings).certainty(Certainty::inconclusive).build();
4041
4142 void run() override {
4243 mNewTemplate = true;
@@ -183,13 +184,12 @@ class TestNullPointer : public TestFixture {
183184 {
184185 bool inconclusive = false;
185186 bool cpp = true;
186- Standards::cstd_t cstd = Standards::CLatest;
187187 };
188188
189189#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
190190 template<size_t size>
191191 void check_(const char* file, int line, const char (&code)[size], const CheckOptions& options = make_default_obj()) {
192- const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, options.inconclusive).c(options.cstd).build() ;
192+ const Settings& settings1 = options.inconclusive ? settings_i : settings ;
193193
194194 // Tokenize..
195195 SimpleTokenizer tokenizer(settings1, *this, options.cpp);
@@ -199,6 +199,16 @@ class TestNullPointer : public TestFixture {
199199 runChecks<CheckNullPointer>(tokenizer, this);
200200 }
201201
202+ template<size_t size>
203+ void check_(const char* file, int line, const char (&code)[size], bool cpp, const Settings& s) {
204+ // Tokenize..
205+ SimpleTokenizer tokenizer(s, *this, cpp);
206+ ASSERT_LOC(tokenizer.tokenize(code), file, line);
207+
208+ // Check for null pointer dereferences..
209+ runChecks<CheckNullPointer>(tokenizer, this);
210+ }
211+
202212#define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__)
203213 template<size_t size>
204214 void checkP_(const char* file, int line, const char (&code)[size]) {
@@ -1338,7 +1348,8 @@ class TestNullPointer : public TestFixture {
13381348 check(code); // C++ file => nullptr means NULL
13391349 ASSERT_EQUALS("[test.cpp:4:11]: (error) Null pointer dereference: i [nullPointer]\n", errout_str());
13401350
1341- check(code, dinit(CheckOptions, $.cpp = false, $.cstd = Standards::C17)); // C17 file => nullptr does not mean NULL
1351+ const Settings s = settingsBuilder(settings).c(Standards::C17).build();
1352+ check(code, false, s); // C17 file => nullptr does not mean NULL
13421353 ASSERT_EQUALS("", errout_str());
13431354
13441355 check(code, dinit(CheckOptions, $.cpp = false));
0 commit comments