File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -290,6 +290,7 @@ class TestTokenizer : public TestFixture {
290290 TEST_CASE (cppMaybeUnusedBefore);
291291 TEST_CASE (cppMaybeUnusedAfter1);
292292 TEST_CASE (cppMaybeUnusedAfter2);
293+ TEST_CASE (cppMaybeUnusedAfter3);
293294 TEST_CASE (cppMaybeUnusedStructuredBinding);
294295
295296 TEST_CASE (attributeAlignasBefore);
@@ -4381,6 +4382,19 @@ class TestTokenizer : public TestFixture {
43814382 ASSERT (var && var->isAttributeMaybeUnused ());
43824383 }
43834384
4385+ void cppMaybeUnusedAfter3 () {
4386+ const char code[] = " void foo(int x [[maybe_unused]]) {}" ;
4387+ const char expected[] = " void foo ( int x ) { }" ;
4388+
4389+ SimpleTokenizer tokenizer (settingsDefault, *this );
4390+ ASSERT (tokenizer.tokenize (code));
4391+
4392+ ASSERT_EQUALS (expected, tokenizer.tokens ()->stringifyList (nullptr , false ));
4393+
4394+ const Token *x = Token::findsimplematch (tokenizer.tokens (), " x" );
4395+ ASSERT (x && x->isAttributeMaybeUnused ());
4396+ }
4397+
43844398 void cppMaybeUnusedStructuredBinding () {
43854399 const char code[] = " [[maybe_unused]] auto [var1, var2] = f();" ;
43864400 const char expected[] = " auto [ var1 , var2 ] = f ( ) ;" ;
You can’t perform that action at this time.
0 commit comments