@@ -90,14 +90,22 @@ class TestUnusedFunctions : public TestFixture {
90
90
TEST_CASE (attributeMaybeUnused);
91
91
}
92
92
93
+ struct CheckOptions
94
+ {
95
+ CheckOptions () = default ;
96
+ Platform::Type platform = Platform::Type::Native;
97
+ const Settings* s = nullptr ;
98
+ bool cpp = true ;
99
+ };
100
+
93
101
#define check (...) check_(__FILE__, __LINE__, __VA_ARGS__)
94
102
template <size_t size>
95
- void check_ (const char * file, int line, const char (&code)[size], Platform::Type platform = Platform::Type::Native, const Settings *s = nullptr, bool cpp = true ) {
96
- const Settings settings1 = settingsBuilder (s ? *s : settings).platform (platform).build ();
103
+ void check_ (const char * file, int line, const char (&code)[size], const CheckOptions& options = make_default_obj() ) {
104
+ const Settings settings1 = settingsBuilder (options. s ? *options. s : settings).platform (options. platform ).build ();
97
105
98
106
// Tokenize..
99
107
SimpleTokenizer tokenizer (settings1, *this );
100
- ASSERT_LOC (tokenizer.tokenize (code, cpp), file, line);
108
+ ASSERT_LOC (tokenizer.tokenize (code, options. cpp ), file, line);
101
109
102
110
// Check for unused functions..
103
111
CheckUnusedFunctions checkUnusedFunctions;
@@ -691,10 +699,10 @@ class TestUnusedFunctions : public TestFixture {
691
699
692
700
const Settings s = settingsBuilder (settings).library (" windows.cfg" ).build ();
693
701
694
- check (" int WinMain() { }" , Platform::Type::Native, &s );
702
+ check (" int WinMain() { }" , dinit (CheckOptions, $. s = &s) );
695
703
ASSERT_EQUALS (" " , errout_str ());
696
704
697
- check (" int _tmain() { }" , Platform::Type::Native, &s );
705
+ check (" int _tmain() { }" , dinit (CheckOptions, $. s = &s) );
698
706
ASSERT_EQUALS (" " , errout_str ());
699
707
}
700
708
@@ -707,10 +715,10 @@ class TestUnusedFunctions : public TestFixture {
707
715
708
716
const Settings s = settingsBuilder (settings).library (" windows.cfg" ).build ();
709
717
710
- check (" int wWinMain() { }" , Platform::Type::Native, &s );
718
+ check (" int wWinMain() { }" , dinit (CheckOptions, $. s = &s) );
711
719
ASSERT_EQUALS (" " , errout_str ());
712
720
713
- check (" int _tmain() { }" , Platform::Type::Native, &s );
721
+ check (" int _tmain() { }" , dinit (CheckOptions, $. s = &s) );
714
722
ASSERT_EQUALS (" " , errout_str ());
715
723
}
716
724
@@ -723,7 +731,7 @@ class TestUnusedFunctions : public TestFixture {
723
731
const Settings s = settingsBuilder (settings).library (" gnu.cfg" ).build ();
724
732
725
733
check (" int _init() { }\n "
726
- " int _fini() { }\n " , Platform::Type::Native, &s );
734
+ " int _fini() { }\n " , dinit (CheckOptions, $. s = &s) );
727
735
ASSERT_EQUALS (" " , errout_str ());
728
736
}
729
737
@@ -811,10 +819,10 @@ class TestUnusedFunctions : public TestFixture {
811
819
812
820
void attributeMaybeUnused ()
813
821
{
814
- check (" [[__maybe_unused__]] void f() {}\n " , Platform::Type::Native, nullptr , false );
822
+ check (" [[__maybe_unused__]] void f() {}\n " , dinit (CheckOptions, $. cpp = false ) );
815
823
ASSERT_EQUALS (" " , errout_str ());
816
824
817
- check (" [[maybe_unused]] void f() {}\n " , Platform::Type::Native, nullptr , false );
825
+ check (" [[maybe_unused]] void f() {}\n " , dinit (CheckOptions, $. cpp = false ) );
818
826
ASSERT_EQUALS (" " , errout_str ());
819
827
820
828
check (" [[maybe_unused]] void f() {}\n " );
0 commit comments