2222#include " helpers.h"
2323#include " preprocessor.h"
2424#include " settings.h"
25- #include " standards.h"
2625
2726#include < list>
2827#include < string>
29- #include < vector>
3028
3129class TestUnusedVar : public TestFixture {
3230public:
@@ -281,21 +279,19 @@ class TestUnusedVar : public TestFixture {
281279 {
282280 CheckStructMemberUsageOptions () = default ;
283281 const std::list<Directive>* directives = nullptr ;
284- const Settings *s = nullptr ;
282+ bool cpp = true ;
285283 };
286284
287285#define checkStructMemberUsage (...) checkStructMemberUsage_(__FILE__, __LINE__, __VA_ARGS__)
288286 void checkStructMemberUsage_ (const char * file, int line, const char code[], const CheckStructMemberUsageOptions& options = make_default_obj()) {
289- const Settings *settings1 = options.s ? options.s : &settings;
290-
291287 // Tokenize..
292- SimpleTokenizer tokenizer (*settings1 , *this );
288+ SimpleTokenizer tokenizer (settings , *this );
293289 if (options.directives )
294290 tokenizer.setDirectives (*options.directives );
295- ASSERT_LOC (tokenizer.tokenize (code), file, line);
291+ ASSERT_LOC (tokenizer.tokenize (code, options. cpp ), file, line);
296292
297293 // Check for unused variables..
298- CheckUnusedVar checkUnusedVar (&tokenizer, settings1 , this );
294+ CheckUnusedVar checkUnusedVar (&tokenizer, &settings , this );
299295 (checkUnusedVar.checkStructMemberUsage )();
300296 }
301297
@@ -1831,8 +1827,6 @@ class TestUnusedVar : public TestFixture {
18311827 ASSERT_EQUALS (" [test.cpp:1]: (style) struct member 'A::i' is never used.\n " ,
18321828 errout_str ());
18331829
1834- /* const*/ Settings s = settings;
1835- s.enforcedLang = Standards::Language::C;
18361830 checkStructMemberUsage (" struct A {\n " // #10852
18371831 " struct B {\n "
18381832 " int x;\n "
@@ -1841,7 +1835,7 @@ class TestUnusedVar : public TestFixture {
18411835 " void f() {\n "
18421836 " struct B* pb = &a.b;\n "
18431837 " pb->x = 1;\n "
1844- " }\n " , dinit (CheckStructMemberUsageOptions, $.s = &s ));
1838+ " }\n " , dinit (CheckStructMemberUsageOptions, $.cpp = false ));
18451839 ASSERT_EQUALS (" " , errout_str ());
18461840
18471841 checkStructMemberUsage (" union U {\n "
@@ -1859,7 +1853,7 @@ class TestUnusedVar : public TestFixture {
18591853 " pb->x = 1;\n "
18601854 " struct C* pc = &u.c;\n "
18611855 " pc->s[0] = 1;\n "
1862- " }\n " , dinit (CheckStructMemberUsageOptions, $.s = &s ));
1856+ " }\n " , dinit (CheckStructMemberUsageOptions, $.cpp = false ));
18631857 ASSERT_EQUALS (" " , errout_str ());
18641858 }
18651859
0 commit comments